To create enemy waves

enemy waves gamemaker

To create enemy waves

You need to have folled the followed the tutorial on creating a persistent object to hold the score.

  1. Add the global variable to the Create event of objVarPersist:
  2. Create an object called objEnemyWaves
  3. Add a Create event to the object with the following code:
    //wait 10 seconds for the alarm for the first time
  4. Add an Alarm 0 event with the following code:
    //increment the wave
    //Change the following or choose not to use them at all it is up to you
    //take 5 from the high spawn rate value
    //add 5 to enemy count
    alarm[0] = room_speed*10; //trigger every 10 seconds
  5. Add objEnemyWaves to the room
  6. You can show which wave you are on by adding the following to the Draw event of objScore:
    draw_text(100, 10, "Wave: " + string(global.wave));
  7. If you want to spawn different enemies on odd and even waves, wrap the instant_create_layer() method in and if statement like the following. Note you will have to create a second enemy sprite and enemy object. Give the second enemy object a different speed, movement and health also if you like
    if((instance_number(objEnemy) < maxEnemies)){
     if(global.wave%2==1){ //check if there is one leftover, therefore odd
     instance_create_layer(irandom(room_width), irandom_range(0,50), layer, objEnemy);
     }else{ //on the even waves
     instance_create_layer(irandom(room_width), irandom_range(20,50), layer, objEnemy2);
Latest posts by Tomas (see all)

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top