liveBook · Manning

Enemy

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

An opposing game entity that threatens or obstructs the player or playable characters.

An enemy is a game entity that threatens or obstructs the player. In an NES game loop, enemies are spawned, stored, moved, and eventually checked for collisions with the player or other objects. section 1.5.3 section 11.0

Handle enemies as a sequence of game-loop tasks:

  • Initialize or spawn an enemy by choosing its type, placing its sprite or sprites, and setting control data in a RAM table. section 1.5.3
  • Move each existing enemy according to its position and state, reacting to background boundaries, the player, or player actions. section 1.5.3
  • Detect collisions between the player and enemies, then animate the player’s death, reduce lives, or show Game Over when appropriate. section 11.0
  • Increase challenge through level progression, additional enemy types, or more complex movement. section 8.4 section 1.6

Planning enemy storage

An enemy may use up to four separate sprites. Supporting ten enemies therefore reserves as many as forty of the NES’s sixty-four available sprites, leaving the remaining sprite capacity for the player and other objects. Keeping enemy logic in separate functions makes later changes easier. section 8.4

Random enemy selection can vary by level or player actions, but limited 8-bit computation makes random-number generation costly. An external factor from the player can make results less predictable without excessive computation. section 1.5.3 section 8.4

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

How deep it goes
Explains spawning, RAM state, movement, sprite limits, and collision consequences while deferring detailed movement implementation.
Examples
Illustrates shoot-em-up enemies, random enemy selection, ten enemies using forty sprites, and player-enemy collision leading to Game Over.
What you can do after
Build it from scratch by spawning enemies, storing their state, moving them, and integrating player-collision consequences.
How it connects
Connects enemies with the game loop, RAM tables, sprites, collision detection, player input, level progression, and difficulty.

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.