This week, levels have a goal to reach, and reaching the goal loads the next level.
You can also die, and revive players by touching the spawn point again.
Level Goals
I implemented exactly the same thing as Broforce, because if it was good enough 9 years ago, it's good enough today, right?
LDTK (our level editor - see last week) has support for "entities", which are just rectangles you can name and place in the level. So both spawn and exit points are created as entities.
Unfortunately I didn't design the test scene file format (still in use for non-LDTK levels, for debugging specific atom behaviors that need higher resolution than tiles) for arbitrary entities, so I made a little migration process to convert the existing test scenes over to the new format. In hindsight the migration was not really worthwhile - I should have just recreated the test scenes I still care about from scratch.
Player Death
Implementing "you beat the level" lead me to make (what was supposed to be) a quick detour to also add "you failed the level": previously, dying would instantly respawn your character so you would never actually fail.
Several hours of reworking my input-handling logic later1, you now stay dead until another player revives you:
Eventually I expect to have a "Revive" spell that players cast, or maybe (again) the Broforce approach of reviving players at checkpoints if there are lives left.
If all players die, I just reload the existing level.
Playable web build
Here, enjoy 3 glorious levels, back to back:
Notes:
- Yep we have menus now. Loading levels is done via the
File
menu now. - You can't drop out as a player anymore. I was going to add a menu option for it rather than a dedicated keybinding, but it doesn't seem particularly important right now.
I had unwisely de-coupled my input handling and game logic for adding a player, so that new players were added automatically based on the input that was read... and if there was any input from an existing control map for a player who didn't exist anymore (because they died), the game would crash. Whoops.