Hello,
Looking at the events that monsterSpeed variable is used four places.
1. Where the variable is made as a global variable.
2. Where it’s increased every time an enemy is killed.
3. Under the every 3 seconds, it’s used to set the speed of newly created enemy.
4. And when you hit space to reset the game. It’s set back to an initial small value. Most things get reset automatically when restarting or changing layouts, but when something is global it doesn’t reset automatically. This is useful for keeping scores between layouts or stuff like that. So anyways, in this case they wanted to reset it and not keep its value so it was done manually.
I agree with you about the comment. It’s increasing the speed of the new enemies, not the rate they spawn.
There seems to be lots of YouTube channels with video tutorials that may be useful to you. Especially if they explain what they are trying to do and explain each part.
Anyways, here are my thoughts on how I’d come up with some of the enemy events.
So first we have some enemies. We want them to move forward so we give them the bullet behavior and see them happily trudging forward.
If it’s too fast or slow we adjust the speed in the layout editor.
Ok cool. But these enemies seem pretty dumb. The player can avoid them easily. How about we have them chase the player? One way to do that is to change their angle to face the player.
Every tick:
— enemy: set angle towards (player.x, player.y)
We test that and the enemies turn instantly to the player and pile up on him. The player can only get away if they are faster.
So what if we made the the turning more gradual? Like maybe turn 1degree per frame toward the player? That would look like:
Every tick
— enemy: rotate 1 degree towards (player.x, player.y)
The result is kind of nice now. Even is the enemies are a bit faster than the player you can out turn them. It gives the enemies a lumbering zombie like quality.
However all the enemies seem to know where the player is at all times. What if their senses were more realistic. Like they could only detect the player if they were close enough.
So how would we do that? There isn’t a compare distance condition. But we could use the compare values condition with an expression. There’s an expression called “distance” that will give you the distance between two points. So how close should the enemy and player be between each other for the enemy to year. Let’s say 200 or less so every position in a 200 pixel radius circle
So we can change our event to
Every tick
Compare two values distance(player.x,player.y,enemy.x,enemy.y<200
— enemy: rotate 1 degree toward (player.x, player.y)
You can actually remove the every tick condition, since events are run every tick already.
So anyways we test this and something seems amiss. It will work perfectly with a single enemy but with multiple it will seem to work with only the first enemy and not the rest. The reason has to do with picking. The system compare condition does no picking. It just uses the position of the first enemy instance in that distance calculation.
Anyways we need to find the distance between each enemy and the player. One solution is use for each enemy to do that. What for each does is look at each instance one at a time.
So the result is:
For each enemy
Compare two values distance(player.x,player.y,enemy.x,enemy.y<200
— enemy: rotate 1 degree toward (player.x, player.y)
Which works how we want it.
Alternatively we could use a different condition like pick by comparison. It only will pick the enemies inside that radius. It will work the same for our purposes.
System: Pick enemy by comparison: distance(player.x,player.y,enemy.x,enemy.y<200
— enemy: rotate 1 degree toward (player.x, player.y)
Anyways, hope some of that helps. I don’t have time to screenshot events so hopefully that text makes sense. I don’t usually write things so detailed but that is my thought process when I make events. The difference is over time you find more features you can utilize.
-cheers