MicrolearnENPTES

Enemies and lives

Lesson 8 of 16 · GDev.Micro

Rewards need risk. An enemy patrolling the ground gives the player a reason to jump and a way to lose.

When the Player touches an Enemy, subtract 1 from Lives and delete that enemy, so one touch costs exactly one life. Deleting the picked enemy works just like deleting a picked coin.

A second event watches the result: when Lives reaches 0, show Game over. Keeping “what happens” apart from “what it means” keeps each event simple.

Real projects usually give the player a few seconds of invincibility after a hit instead of deleting the enemy. Same idea, more polish.

Touching an Enemy costs one life and removes that enemy. At 0 lives, show Game over.

Do it in the browser: a real game design tool, a short mission and instant feedback. No install.

Start this lesson — free
← Timers and spawningThe core loop →

All lessons · GDev.Micro