liveBook · Manning

Animation

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

Animation is the presentation of changing visual states over time to create motion or visual activity in a game.

Animation creates visual activity by changing an object’s displayed pattern, tile, or color over time. In a game loop, it sits alongside input, movement, collisions, spawning, and level progression, helping moving and stationary objects feel active. section 1.5.3 section 13.0

A practical animation sequence stores a starting and ending pattern for an object, then advances its current pattern at controlled intervals. When the next pattern reaches the end, it returns to the starting pattern; objects with only one pattern are skipped. section 13.1

On the NES, animation can be built through several small, frame-aware changes:

  • Cycle an enemy sprite through pattern numbers. Single-sprite enemies advance by one pattern; four-sprite enemies advance the first pattern by four and assign consecutive patterns to the remaining sprites. section 13.1
  • Replace background tile patterns, such as alternating stored star locations between two star shapes to create twinkling. section 13.2.1
  • Change palette entries in RAM so every tile using those colors changes when the palette is copied to the PPU. section 13.2.2
  • Use effects such as screen shaking and rapid color cycling to make an enemy mine impact appear larger and more dramatic. section 13.0

Timing is part of the effect. Updating an enemy or star on every tick can make the change too quick to see, so a time counter can gate updates. Background changes also must respect the limited amount of video-memory writing available each frame, especially on NTSC consoles. section 13.1 section 13.2

Twinkling stars

Place stars at random screen locations, save each name-table address, and call a short routine from the NMI. After enough time passes, the routine selects one of two star patterns from a time bit and writes it to every saved location. Clear the saved locations when returning to the title screen so later updates cannot write to stale video-memory addresses. section 13.2.1

Listing 13.2 Animating each enemy (Megablast.s)
@nohitbottom:
 
    lda enemydata+3,y
    cmp #1              #1
    beq :+
    lda oam,x           #2
    sta oam+4,x
    clc
    adc #8
    sta oam+8,x
    sta oam+12,x
: 

This listing shows the surrounding enemy-update path in which animation is added after movement, before the pattern-cycling checks and updates. section 13.1

Animation can add appeal without changing gameplay rules: cycling enemy patterns, twinkling stars, palette changes, explosions, and game-over presentation make a playable space shooter feel more lively while preserving its core movement and collision systems. section 11.5 section 13.2.2

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

How deep it goes
Works through timed sprite-pattern cycling, NMI tile updates, palette swaps, and NES video-memory constraints.
Examples
Uses cycling meteor enemies, randomly placed twinkling stars, palette-swapped scenery, and explosion effects.
What it assumes
Introduces animation through an evolving game while relying on existing movement, time-counter, NMI, and PPU-update routines.
What you can do after
Build it from scratch by cycling sprite patterns, updating background tiles, and swapping palette colors on timed intervals.
How it connects
Connects animation with game loops, sprites, tile patterns, palettes, NMI routines, PPU, and video memory.

Also explained in

Compare how 5 books explain animation →

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.