Object Spawning Help

I

Ike

Guest
So for this game I'm doing, I followed GravityShift Games' tutorial on making and Endless Runner but I'm expanding on it. Basically, i have an object that spawns enemies until the players gets to a certain score. Then it stops spawning enemies and spawns a jetpack that essentially triggers the player to go to the next room and continue the game in a different room. The problem is when the player does go to the next room, the enemies still won't spawn and I can't for the life of me figure out why. It's probably something simple but I can't figure it out. Here's my code in my obj_controller:

Alarm 0
randomize();
var count = irandom_range(1,2);

if room = !rm_start && !transition {
scr_obstacle();
alarm[0] = room_speed * random_range(1/global.speedModifier, 3/global.speedModifier);
}



if score >= 300 {
if score < 400 {
transition = true;
scr_jetpack();
if score < 300 {
transition = false;
}
}
}
else {
transition = false;
}

if global.gameOVer || global.transition {
exit;
}

Step Event
if !blastoff {
layer_hspeed("Background",(-global.speedModifier*6));
layer_hspeed("Transition",(-global.speedModifier*6));
layer_hspeed("Inside",(-global.speedModifier*6));

if global.gameOVer {
exit;
}

global.speedModifier += 0.0005;
if room != rm_start {
score += 1 * global.speedModifier;
}

if score >= 300 {
if score < 400 {
transition = true;
if score < 300 {
transition = false;
}
}
}
else {
transition = false
}

}

if blastoff {
layer_hspeed("Background",0);

}
 

FrostyCat

Member
Do you know the difference between this (wrong):
Code:
room = !rm_start
And this (right)?
Code:
room != rm_start
This is at least the third time over the past few weeks that "students" posted improper inequality comparisons. When did it become acceptable to be this ignorant about basic operators? Surely the precious tutorials you've watched should have taught you how to use != properly.
 
I

Ike

Guest
Thanks for that, but funny enough after making that change, everything is still doing the same thing it did before.
 

Rob

Member
I don't see where you're spawning enemies in this code.

Hopefully you have it set up as something simple like:

Code:
if (global.monsters_can_spawn == true){

//spawn monster code goes here

}
And you just set that global variable to true or false.
 
I'd assume obj_controller is a persistent object? If so, your score carries over, so if you've reached too high a score to spawn enemies in the first room they still won't spawn in the second room. Maybe make a separate variable that counts up at the same time as score but resets to zero at the start of each room.
 

samspade

Member
I'd assume obj_controller is a persistent object? If so, your score carries over, so if you've reached too high a score to spawn enemies in the first room they still won't spawn in the second room. Maybe make a separate variable that counts up at the same time as score but resets to zero at the start of each room.
That is a good catch. Score is in fact global so the object doesn't even need to be persistent.

https://docs2.yoyogames.com/source/_build/3_scripting/3_gml_overview/built_in_variables/score.html
 
Top