liveBook · Manning

Enemy movement

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

Enemy movement is a game technique that updates enemy positions over time according to movement rules.

Enemy movement updates enemy positions during the game loop according to stored movement rules. A simple version moves meteors downward from random positions near the top of the screen until they reach the planet’s surface. section 8.3

A basic movement routine follows this process:

  • Loop through the enemy slots and skip entries whose active-data flag is clear. section 8.3

Extending movement for richer enemies

Store each enemy’s horizontal change, vertical change, size, sprite count, and score value in enemy data. Apply DX to X and DY to Y, remove enemies that reach the ground, check collisions with the player and the player’s bullet, update lives or score, and advance through the enemy records. section 12.4 section 12.0

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

How deep it goes
Explains assembly-level loops, OAM updates, movement deltas, boundary removal, collision checks, and enemy-data traversal.
Examples
Demonstrates descending meteors, multi-sprite enemies, directional movement, ground impacts, player collisions, and bullet hits.
What it assumes
Assumes an existing NES game loop, enemy data, sprites, spawning, OAM, and player or bullet state.
What you can do after
Build enemy movement from scratch in NES assembly, then extend it with movement data, collision responses, animation, lives, and scoring.
How it connects
Connects enemy movement with the game loop, enemy spawning, sprite animation, collision detection, player lives, and scoring.

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.