2019-07-31 00:50:46

Hi guys. So I made enemes spawn by putting a line on the bgt script I use for maps. As I said, it only spawns a little gang of enemies, like 5. What can I do to make them spawn untill you exit, and I want them to drop items. Here is the code for the enemies in the map bgt script. for (uint i=0; i<=random(2,30); i++)
{
spawn_enemy(random(25,maxx),0,random(5,25));
}
That is what I am orking with. Don't know what number to change, or do I need to make a timer. Help would be cool.

2019-07-31 01:29:33

Yes you need to make a timer, and make the while loop continuusly check it, and if it reaches the time you desire to restart and spawn.

Lamas with hats, but with sponge bob as carl Stay tuned.

https://www.youtube.com/channel/UCvAUQt … subscriber

2019-07-31 04:14:59

if(enemyspawntimer.elapsed>=espawntime) {
enemyspawntimer.restart();
for (uint i=0; i<=random(2,30); i++)
{
spawn_enemy(random(25,maxx),0,random(5,25));
}
}

Ivan M. Soto.
Feel free to check out my work and services.
http://ims-productions.com

2019-07-31 12:53:47

Do you even know what your code in post 1 does, exactly?

The only reason I replied is because this for loop does not do what you think it does:
first, i is initialized to 0. Then, each time the guard is executed (i <= random(2,30)) a new random number is generated. So it makes sense that this loop only executes about 5 times.

This question is the somewhat more advanced version of "I know 5 * 5 = 25, what should 6 * 5 be?" please, please try the example games from the bgt manual, those are very well commented and will teach you what's going on. If you don't understand those, read the language tutorial. If you don't understand the language tutorial, although this might be harsh, stop programming.

Roel
golfing in the kitchen

2019-07-31 18:05:50

Yeha, @4 is correct. BGT has one of the easier language tutorials to understand. And yeah, that loop doesn't do what you think it does

2019-07-31 19:13:09

I also find it odd how someone who seemingly doesn't even understand the basics of timers is supposedly making a game with enemies and stuff. Things don't quite add up here. Know what I'm saying?

2019-07-31 19:59:10

I kinda agree with charlie.