Trouble With Level System [Gammaker Studio]

Started by
1 comment, last by Anthony Serrano 7 years, 9 months ago

I am working on a scrolling shooter and I want certain objects to only spawn once a specific wave has been reached. Currently I have a object that Initializes a variable called "wave" and calls an alarm to increase the wave variable by one every 450 frames. I know this works as a have a GUI element that displays the wave number. I have another object that is supposed to spawn enemies once the wave reaches a certain variable, however when the wave has reached that variable nothing spawns. If I hard code the specific wave number that the enemy is to spawn it works.

Obj_wave Create:


global.wave = 1;


//next wave
alarm[0] = room_speed*15; 

obj_wave Alarm [0]:


//new wave
global.wave +=1;



//speed up spawn every wave
obj_spawner.spawn_rate -=5;

//call alarm
alarm[0] = room_speed*15;
 

Obj_spawner Create:


randomize();
spawn_rate = 50;
spawn_rate1 = 200;
spawn_rate2 = choose(200,400,600);
spawn_rate3 = choose(200,300,400);
spawn_rate4 = choose(500,700);

alarm[0]= spawn_rate;
alarm[1]= spawn_rate1;
alarm[2]= spawn_rate2;
alarm[3]= spawn_rate3;
alarm[4]= spawn_rate4; 

obj_spawner alarm[1]:


//random y
randomize();
randY = floor(random(room_height));

//create asteroid

if(global.wave>=2){
instance_create(room_width+40,randY, obj_shooter);
alarm[1] = spawn_rate1;
} 

I am working on a scrolling shooter and I want certain objects to only spawn once a specific wave has been reached. Currently I have a object that Initializes a variable called "wave" and calls an alarm to increase the wave variable by one every 450 frames. I know this works as a have a GUI element that displas the wave number. I have another object that is supposed to spawn enemies once the wave reaches a certain variable, however when the wave has reached that variable nothing spawns. If I hard code the specific wave number that the enemy is to spawn it works.

Advertisement

Which wave is failing? 0, 1, 2+?

Knowing nothing of GameMaker Studio... I assume assigning a number to those Alarm objects schedules that alarm's script to run that many frames later? If not, what are those lines intended to do?

In alarm[1], what does the last line do, and are you certain that the variable spawn_rate1 is in scope at that point?

RIP GameDev.net: launched 2 unusably-broken forum engines in as many years, and now has ceased operating as a forum at all, happy to remain naught but an advertising platform with an attached social media presense, headed by a staff who by their own admission have no idea what their userbase wants or expects.Here's to the good times; shame they exist in the past.

I see the problem. Change


if(global.wave>=2){
instance_create(room_width+40,randY, obj_shooter);
alarm[1] = spawn_rate1;
} 

to


if(global.wave>=2){
instance_create(room_width+40,randY, obj_shooter);
} 
alarm[1] = spawn_rate1;

Right now, "alarm[1] = spawn_rate1" only gets performed if global.wave>=2. Since that alarm goes off before the wave alarm does (so global.wave is still 1), the alarm never gets reset, and so the timer stops right there.

This topic is closed to new replies.

Advertisement