📚 Encyclopedia

Games & Graphics · updated 2026-10-13

Architecture for a 2D action game in Godot 4

godotarchitecturestate-machinecomponentsresourcesevent-busaddons

What a 2D action game in Godot 4 should look like structurally, from a five-agent research pass (2026-03-27, 50+ sources; full report at ~/.claude/skills/research/2d-action-games-godot-advanced-engineering.md) and from the technical debt that piled up in "Fight", a side-scrolling shooter that grew to 1,875 lines of GDScript before any of it was applied.

Typical debt in a prototype that grew

Target: three layers

  1. Visual layer: nodes and scenes, as stateless as possible.
  2. Logic layer: state machines and component nodes.
  3. Data layer: Resource (.tres) files for all tunable data (WeaponStats, EnemyStats, PowerupConfig).

Patterns to adopt

Anti-patterns the research flagged

Future-proofing, monolith scripts, editor-wired signal connections at scale, and object pooling by default (Godot's allocation is cheap enough; pool only after measuring).

LimboAI (about 2,600, behavior trees plus FSM in C++ with a visual debugger), Phantom Camera (about 3,200, follow/shake/zoom), GUT (about 2,400, unit testing), Aseprite Wizard (about 1,200), Input Helper (about 1,000, device detection), Sound Manager (about 740, audio pooling), GODOT-VFX-LIBRARY (about 217).

Enemy AI ideas that worked cheaply

Aggro memory (keep chasing 3 s after losing sight), alert propagation to nearby enemies, ranged enemies that retreat to keep distance, aim prediction, staggered random attack delays, sentry vs patrol variety, difficulty scaling by level position, knockback resistance per type, a wave system (3 + 2 * wave enemies, mix weighted by wave).

Sprite sheet import tip

A single strip sheet with variable frame widths (2889 x 72 px, 40 frames) can be sliced with a short PIL script that finds frame boundaries by empty columns, normalizes frames onto fixed canvases (64 x 48), and writes SpriteFrames resources per animation.

See also

Linked from

Sources: gd-fight memory (project_architecture, reference_research, project_tasks, project_completed_work)