[SOLVED] Spawning 5 different bosses every 10 lvls

J

Johnathan

Guest
okay so basically I have 5 bosses. My game has an unlimited number of levels where enemies increase in difficulty.

what I'm looking for is:

Boss 1 spawns at lvl 10 60 110 160 etc
Boss 2 spawns at lvl 20 70 120 170 etc
Boss 3 spawns at lvl 30 80 130 180
Boss 4 spawns at lvl 40 190 140 190 etc
Boss 5 spawns at lvl 50 100 150 200 etc

i can't seem to get a formula to do this.
 
All of those patterns can be described in simple linear equations.

Boss 1: y = 50x + 10;
Boss 2: y = 50x + 20;
etc.

So if you really want a formula, then that is how.

However, it may be simpler just to spawn a boss every 10 levels, and choose a boss from a list which increments by one each time you spawn one.

Create
Code:
boss = 1;
Room start, or wherever you spawn enemies. This is just an example:
Code:
if (lvl%10 == 0)
 {
 instance_create(asset_get_index("obj_boss"+string(boss), x, y);
 boss ++;
 if (boss == 6)
  {
  boss = 1;
  }
 }
 
R

ramen

Guest
Also worth noting is the switch statement..

Code:
switch lvl
    {
    case 10:
        {
        //spawn your boss here
        break;
        }
}
Not a real formula, but a good method for lists of things to do..
 
J

JFitch

Guest
Save the bosses as an array.
Code:
boss[0]=...
boss[1]=...
boss[2]=...
boss[3]=...
boss[4]=...
You can then access it using:
Code:
if level mod 10==0 // this line tests whether it's a boss level
boss[(level mod 50)/10] // this line decides which boss
That is not a complete code. Each line is just a suggestion for how to do something.
 
J

Johnathan

Guest
The main problem I am having is when I reach level 60 it seems to be doing lvl /10 = 6 which brings it to option 6. then if I fail on the boss the increment still goes up. perhaps i could put the increase in the boss but It also has the option to pick previous levels. So for example if I beat the boss on level 60 boss1 lvl2, then pick levels 41 through 50. it calculates that increase so though i went back to boss on level 50 it is spawning the boss for 70. When I get to level 60 it should be spawning boss 1 again.

I seemed to fail to mention that you could pick previous level blocks.
 

FrostyCat

Member
The main problem I am having is when I reach level 60 it seems to be doing lvl /10 = 6 which brings it to option 6. then if I fail on the boss the increment still goes up. perhaps i could put the increase in the boss but It also has the option to pick previous levels. So for example if I beat the boss on level 60 boss1 lvl2, then pick levels 41 through 50. it calculates that increase so though i went back to boss on level 50 it is spawning the boss for 70. When I get to level 60 it should be spawning boss 1 again.

I seemed to fail to mention that you could pick previous level blocks.
That's not what JFitch wrote. Read it again.
JFitch said:
Code:
boss[(level mod 50)/10] // this line decides which boss
Tracing this with level set to 60 gives (60 mod 50)/1010/101 as expected.
 
J

Johnathan

Guest
oh okay I see how this works! so just to be certain. I would put the "boss level" in the boss its self would I use something similar in the actual boss done to test the level in which he should build?
 
J

Johnathan

Guest
i built the array to equal the actual boss object and created a variable:
spawn = boss[(global.level mod 50)/10]
instance create spawn

works like a charm Thanks!
 
Top