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
