• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Changing variables based off rooms

B

BladeGamez

Guest
I have a space level that I want to include in my game. Do I simply make my variables global and go into my room and subtract and add to the variable at will? For example, in the space level I want to decrease the jump speed.
 

obscene

Member
Directly input the variable in the room creation code

or...

Use a persistent controller object with a room start event to read the room and set the values accordingly (probably the best way so it's all in once place.
 
P

PandaPenguin

Guest
Do I simply make my variables global and go into my room and subtract and add to the variable at will?
that sounds about right, yes

but what I would do instead if you only have one player object:
add a "other->room start" event to the player object and let it check the room type
Code:
if(room_get_name(room) == "name of your space level room"){
 jump_speed = [your desired jump speed]
}else{
 jump_speed = [your default jump speed]
}
this code will check one time only what jump speed to set for the room and if it is your space level will set the jump speed for space
in all other rooms it will set the jump speed to your default jump speed

this way you won't forget to "reset" your jump speed when you are not in space anymore (which can happen if you use global variables)
 
Top