Devlog: HIGHWAY TO THE DANGER ZONE
Small Changes:
- Added the ability to jump during a slide (experimental, currently disabled).
- Made it easier to execute backflips (experimental, backflips currently disabled).
- Made it harder to land on stairs to reduce abrupt snapping when landing.
- Added Life Doll (1-up collectible).
- Added Harpy - Dropper Enemy (flies straight & drops a fleaman-style enemy).
Water Zones:
Added water zones. Entering water will reduce movement speed for players & enemies. The current implementation can be streamlined a bit when it comes to handling movement speed changes, but water splashes are now handled via a function that may be called in any object. Thus, now both players AND enemies can seamlessly make water splashes.

Enemy Spawn Zone:
This is the main feature of the latest update, and is among the most important objects in the old engine (so it's good we finally have it here -- and better than before). It's very complex.
The spawn zone is responsible for spawning enemies infinitely (this is how medusa heads tend to spawn), and there's a lot going on within the logic. It is more advanced than before, but also more streamlined too. I've been afraid to recreate this object, so I'm glad it went by so smoothly and that it's now (mostly) done.

Starting with [ o_enemy_spawn_zone ]'s [ CREATE ] Event...
We initialize all of the relevant variables that control how the object functions. After placing it inside the room, I can access its Variable Definitions panel to change its properties: what to spawn, where to spawn, the length, trigger tag, etc.


Then we enter the [ STEP ] Event, which runs every computational frame.
Before any of the code, we check to see if the player is currently inside the zone (or a trigger zone with the same global trigger tag). We also begin counting down the spawn timer.
Once the Zone is activated by the previous player check, we count how many enemies have been spawned (so it ignores hand-placed enemies) in order to ensure we never spawn above the assigned max limit.
We can then determine the direction enemies spawn relative to the player, whether that's on the right, left, both sides, front, etc. That will return either a negative (left) or positive (right) 1 to use in an equation that selects a random X coordinate (within a range) for spawning. Then we move onto determining the Y coordinate (which is where it gets a bit more complicated).
For the Y coordinate, airborne enemies determine their own Y coordinate (for instance, the bat spawns at the player's Y while harpies spawn near the top of the screen) and some enemies spawn directly below the camera (like the gillman). Otherwise, we default our spawn to simply match the bottom of the Zone's bounding box (usually the floor).
New to this version of the engine; we now check if that Y coordinate is inside of a solid block. If so, the chosen Y coordinate will be moved up or down to ensure clearance. As a result, we can now spawn enemies at different elevations within the same spawn zone. The old engine required cheating by using Trigger Zones connected to a separate Spawn Zone.
After all that, we determine whether the spawn location is legal; which has 3 conditions:
- Is the Target Point INSIDE the Spawn Zone?
- Is the Target Space FREE (as in NOT within a solid)?
- Is the Target Point DIRECTLY above the ground?
If the position is not legal, then it repeats - looking for a new X and Y position. If the position IS legal, spawn timer is finished, and we have yet to reach the Max Spawn count... We spawn!
When spawning an enemy, we toggle its internal [ can_despawn ] variable to true so that the spawn zone counts it and so the enemy knows to despawn off-camera.

I can probably streamline it a bit more, but it largely works as expected now. If any enemies require specific behavior, like spawning in the air, or counting its sub-spawns, I will need to plug them into the script (which is fairly simple now).
Let's take a look at two extra components. First a SWITCH in the [ ROOM START ] Event. Here, we can define whether an enemy MUST be spawned airborne, like the harpy. This makes it so that enemies are automatically spawned in the specific areas required of them.

We also have [ scr_spawn_count_get ], which is a function used to count all of the enemies spawned by the specific spawner. In it, we count the spawned enemy -- and its sub-spawns.
For instance, let's imagine a spawner has a max limit of 2 spawns. If a harpy is spawned, we have 1 Enemy. The harpy will also spawn a "fleaman", resulting in 2 Enemies. Of course, the harpy flies off screen, so we're back at 1 Enemy. Another harpy appears, back to 2 Enemies. This harpy spawns another fleaman, so now its 3 Enemies. The harpy then flies off, leaving 2 "sub-spawn" fleaman.
The Spawner counts those fleamen as part of the spawn limit, ensuring that no more harpies are spawned until one of the fleamen is removed, preventing the player from getting overrun by a hundred fleamen.

-
Don't forget to eat & sleep.





