Need help with waves

iBack

Member
Code:
 //Next wave or end spawner when all enemies have died
    if (remaining [current_wave]<=0)
    {
       
        if (current_wave == total_waves)
       
        {
       
        //game_restart();
       
        highscore_add(string(""), global.highscoreboard);
        }
        else
        {
            current_wave++
            timer = 0;
    //
    }
I'm still new to GML.
What this code does is it checks the remaining waves (current wave) if its less than or equal to 0.
if current wave is equal to total waves the game will restart, anything else the wave will continue until it reaches total waves. game restart takes me back to title screen and resets score so i dont want to use that.
what i want to do is, once current wave reaches 0, the waves will then go back to the beginning starting from the first wave.

what would i have to write? can someone help me please.
 
S

Silvis

Guest
If I'm understanding this correctly you just need to set the waves to 0 instead of resetting the game.
Code:
//check number of enemy objects
if instance_number(obj_enemy) == 0
{
    //if not on the last wave
    if (current_wave != total_waves)
    {
        current_wave++;
        timer = 0;
    }
    else //no more new waves, reset the waves
    {
        current_wave = 0;
        timer = 0;
    }

    //spawn enemies based on current wave
}
 

iBack

Member
If I'm understanding this correctly you just need to set the waves to 0 instead of resetting the game.
Code:
//check number of enemy objects
if instance_number(obj_enemy) == 0
{
    //if not on the last wave
    if (current_wave != total_waves)
    {
        current_wave++;
        timer = 0;
    }
    else //no more new waves, reset the waves
    {
        current_wave = 0;
        timer = 0;
    }

    //spawn enemies based on current wave
}
Thank you very much it worked. you were very helpful, thank you very much.
 
Top