VectorRen games are intentionally small, isolated, and behavior‑driven.
Even though no game shares code, they do share ideas.
This document captures the recurring conceptual patterns that appear across games — movement, collisions, spawning, timing, input, and world rules.
These patterns are conceptual, not prescriptive.
They describe how things behave, not how they are implemented.
Movement in VectorRen is deterministic and time‑based.
Entities move according to their velocity, and velocity changes according to forces or input.
Given an entity with position and velocity
When time advances
Then its position changes by velocity multiplied by elapsed time
Given an entity with angular velocity
When time advances
Then its rotation changes accordingly
Given an entity with acceleration
When time advances
Then its velocity changes by acceleration multiplied by elapsed time
Given a ship facing a direction
When thrust is applied
Then its velocity increases along that direction
Movement patterns should be simple, predictable, and testable.
VectorRen games often use a bounded world where entities wrap around edges.
Given an entity beyond the right boundary
When wrapping is applied
Then it appears on the left boundary
Given an entity beyond the top boundary
When wrapping is applied
Then it appears on the bottom boundary
Given an entity outside any boundary
When wrapping is applied
Then it reappears on the opposite side
Wrapping keeps the world continuous and avoids invisible dead zones.
Collisions in VectorRen are conceptual, not pixel‑based.
They rely on simple geometric rules.
Given two entities with collision radii
When the distance between them is less than the sum of their radii
Then a collision occurs
Given a bullet and an asteroid
When a collision occurs
Then both are removed and the score increases
Given a large asteroid
When it is destroyed
Then two smaller asteroids appear with new velocities
Collision patterns should be deterministic and easy to reason about.
Spawning introduces new entities into the world.
Given a spawn timer
When the timer expires
Then a new entity appears and the timer resets
Given a destroyed entity
When a specific condition is met
Then new entities appear
Given a spawn region
When an entity is created
Then its position and velocity are chosen from a controlled random range
Randomness should be bounded and testable.
Input affects behavior, not rendering.
Given a key is held
When input is processed
Then the associated action continues
Given a key is pressed
When input is processed
Then a single action occurs
Given an action with a cooldown
When the player triggers it
Then it cannot be triggered again until the cooldown expires
Input patterns should be simple and predictable.
Timing governs updates, cooldowns, and lifetimes.
Given a previous timestamp and a current timestamp
When the game updates
Then elapsed time is the difference between them
Given an action with a cooldown
When the action is used
Then the cooldown timer starts and must reach zero before reuse
Given an entity with a lifetime
When time advances
Then the entity is removed when its lifetime expires
Timing patterns keep the game deterministic.
State is explicit, minimal, and easy to inspect.
Each entity tracks only what it needs:
- position
- velocity
- rotation
- radius
- flags
The world tracks:
- entities
- timers
- score
- lives
- input state
Given a state update
When applying changes
Then produce a new state or a clean mutation
State patterns keep logic clean and testable.
Rendering is separate from behavior.
Given an entity with position and rotation
When rendering
Then apply transforms to its SVG group
Given an entity that persists
When updating
Then its DOM node remains the same and only transforms change
Given visual rules
When styling entities
Then use classes and CSS instead of inline attributes
Rendering patterns keep the DOM readable and debuggable.
Avoid these:
- mixing logic and rendering
- mutating DOM attributes every frame
- deep DOM nesting
- clever abstractions
- hidden state
- random behavior without bounds
- tests that depend on rendering
Patterns should simplify, not complicate.
Patterns are shared knowledge, not shared code.
They help contributors build consistent, explainable games without creating a framework or engine.
Use patterns when they clarify behavior.
Ignore them when they get in the way of fun.