Skip to content

SpaceInvadersEffect

Source: SpaceInvadersEffect.h

SpaceInvadersEffect

class SpaceInvadersEffect
src/light/effects/SpaceInvadersEffect.h:119

Inherits: EffectBase

Effect: Space Invaders in attract mode, marching and firing on its own.

SpaceInvadersEffect card SpaceInvadersEffect controls

The arcade's attract mode is the model: a game playing itself is what reads across a room. The cannon tracks and fires on its own, the ranks march and drop, and a hit thins the formation.

Public Attributes

uint8_t marchBpm = 60 : Steps per minute with a full formation. Thinning ranks raise it from here.

uint8_t stepX = 2 : Pixels the formation slides per step.

uint8_t dropY = 3 : Rows the formation drops when it reaches an edge.

uint8_t size = 1 : Pixels per art pixel. A 64-wide panel wants 1, and a wall can afford 2.

bool audioReactive = false : March on the beat and fire on a transient. Silence holds the invasion still.

Public Methods

virtual inline const char * tags() const override : Catalog tags: the audio glyph applies when audioReactive is set.

virtual inline Dim dimensions() const override : A formation needs a floor and a height, so it is a 2D effect.

virtual inline void defineControls() override : Publish the tempo, the step and drop distances, the sprite scale and the audio switch.

virtual inline void prepare() override : Reset the march clock and deal a fresh formation.

virtual inline void tick() override : Advance the march, then draw the formation, the shots and the cannon.

More info

The march is the signature

In the arcade the formation speeds up as the ranks thin. The machine stepped every invader once per frame, so fewer invaders meant a shorter loop. That accident of 1978 hardware became the game's defining tension. Our loop has no such limit, so stepInterval reproduces the relationship deliberately.