GameMaker Running specific parts of game rather than going thru everything?

T

TheTimmyBoy

Guest
I'm sure this question has been posed before, but how can you load specific rooms? I currently have my code set up in a way to run the game as it would when someone first starts it up: menu, select a save file, then game. But I want to just be able to test certain rooms sometimes without having to go through all that. Is the best option to really just set up a hub room with lots of labelled doors to each of my rooms? Is there really not a way to set up general initialization in GMS and then just run individual rooms that follow that?
 

Morendral

Member
There's a bunch of different ways to do it. Personally i use a console and have commands to set conditions to test whatever i might need
 
T

TheTimmyBoy

Guest
There's a bunch of different ways to do it. Personally i use a console and have commands to set conditions to test whatever i might need
Can you explain that a bit? Kinda new here haha
 

Morendral

Member
A console is usually a sort of drop down interface that you type commands into, and it can give read outs of different information. For your game, you could program commands that would send you to different levels or rooms or whatever it is that you use. Very similar to skyrim or any paradox game
 

samspade

Member
I'm sure this question has been posed before, but how can you load specific rooms? I currently have my code set up in a way to run the game as it would when someone first starts it up: menu, select a save file, then game. But I want to just be able to test certain rooms sometimes without having to go through all that. Is the best option to really just set up a hub room with lots of labelled doors to each of my rooms? Is there really not a way to set up general initialization in GMS and then just run individual rooms that follow that?
No. Not directly. You need to manually set it up. This can be a little bit of a pain, but it also enforces good design practices as it will prevent you from making too many interlocking systems. There are various ways to do so though without to many hassles. For example, let's say you have a controller object which spawns in a bunch of systems. You could create a child of that object that inherits all of the code but then deactivates (or destroys) the systems you don't want. Put that in the test room. And then move the test room to the top. Or just manually change the first room_goto or however you've set it up to go to the test room in code, or upon a certain key press. If this causes errors, you might want to consider restructuring your code. For example, if your enemies cause your game to crash if the player isn't in the room, that just shouldn't be happening. Your camera, menu, etc. should all basically be independent of each other - e.g. not crashing if one exists but the other doesn't.

Also, don't over look testing small portions of the project in their own projects. I do this more and more the larger my project gets. It helps keep the various systems clean and seperated from each other so you don't run into the problems mentioned above.
 
Personally, I have a test object (obj_test). Inside obj_test, I have a create event.

Code:
room_goto( ) //place the room you want here
If there's always a player instance in every room, don't worry about this next part.
If there's no player in that room, you'll need to add one.

Either:
1.) Add the player in the room you're testing via the room editor, then delete it when you're done testing.
2.) In your obj_test, instance_create(x,y,obj_player) AFTER room_goto. //x and y are the coordinates you want the player to be at.

Now all you have to do is put your obj_test in the very first room of your game (the main menu). Now, if you start the game it will take you straight to the desired room instead of the menu.

Keep in mind, if there are any important variables that need to be carried over to this room, you'll have to set those in the obj_test as well.

When you're done testing, remove the obj_test from the first room. Simple!
If you want to change the room you are wanting to test, simply change the name in your room_goto().
 
Top