liveBook · Manning

Life

As explained in Classic Game Programming on the NES: Make your own retro video game

A life is one remaining opportunity for the player to continue a game session after failure or destruction.

A life is the remaining chance to continue after the player ship is hit. The game stores it in a one-byte `lives` counter, starts a new game with five lives, and uses `player_dead` separately to prevent repeated collision handling during the death sequence. section 11.1

When an enemy overlaps the ship, the game decreases `lives`, marks the lives display for updating, sets `player_dead`, and removes the enemy. This separates the immediate collision result from the later animation and restart work. section 11.1

After a life is lost, the game follows a short recovery path:

  • Advance through four explosion shapes over timed stages while the player is dead. section 11.2
  • If lives remain, reset the current level, redraw the player ship, and clear the dead flag. section 11.2
  • If no lives remain, show a Game Over message, wait, clear sprites, and return to the title screen. section 11.3
Listing 11.1 Adding a memory variable for player’s death sequence (Megablast.s)
.segment "ZEROPAGE"
 
time: .res 2
lasttime: .res 1
level: .res 1
animate: .res 1
enemydata: .res 10
enemycooldown: .res 1
temp: .res 10
score: .res 3
update: .res 1
highscore: .res 3
lives: .res 1           #1
player_dead: .res 1     #2
#1 Keeps track of how many lives the player has
#2 Is the player dead? If so, how far through the death animation sequence are we?

The two variables divide responsibilities: `lives` counts remaining attempts, while `player_dead` records whether—and how far—the death sequence has progressed. section 11.1

Lives are displayed as small ship images in two tile rows at the bottom of the screen. The display draws one ship per remaining life, clears tiles left by a previous larger count, and limits the visible display to eight ships so it stays within the available screen space. section 11.4

Awarding an extra life

Extra lives can reward score progress. Keep a `next_extra_life` threshold, compare it with the score’s thousand digit, then advance the threshold, increment `lives`, and flag the display for refresh when the threshold is passed. section 16.1.2

This makes the counter more than a display value: it controls collision recovery, death animation, level restart, game over, and score-based rewards. Each change also requests a screen update so the visible ships match the stored count. section 11.1 section 16.1.2

How Classic Game Programming on the NES: Make your own retro video game covers it

How deep it goes
Builds the counter, collision decrement, death-state progression, bounded display, game-over path, and score-triggered extra-life extension.
Examples
Uses enemy-ship overlap, four explosion stages, ship-tile life icons, a Game Over message, and 5,000-point extra-life thresholds.
What it assumes
Introduces life state through explicit zero-page variables while building on existing enemy movement, score reset, and screen routines.
What you can do after
Build it from scratch by tracking lives, updating the display, restarting after death, and triggering game over at zero.
How it connects
Connects lives with collision detection, death animation, game over, score, sprites, and NMI updates.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Classic Game Programming on the NES: Make your own retro video game. The section links point to the parts of the book it draws on.