Skip to content

feat: add shape cues as a new stimulus channel#6

Merged
manuelmauro merged 4 commits into
mainfrom
feat/shape-cues
Apr 4, 2026
Merged

feat: add shape cues as a new stimulus channel#6
manuelmauro merged 4 commits into
mainfrom
feat/shape-cues

Conversation

@manuelmauro
Copy link
Copy Markdown
Owner

Summary

Adds shape as a 4th n-back stimulus channel. The tile now renders as a geometric shape (circle, triangle, square, pentagon, or hexagon) using 2D meshes instead of a plain sprite.

How it works

When shape cues are enabled in settings, the tile changes shape each round. The player must identify when the current shape matches the one N steps back, just like with position, color, and sound.

Rendering change

The tile switched from Sprite to Mesh2d + MeshMaterial2d<ColorMaterial>:

  • Shape is controlled by swapping the Mesh2d handle (from a TileMeshes resource with pre-built handles)
  • Color is controlled by mutating the ColorMaterial asset

New/modified files

File Change
game/tile/shape.rs New — TileShape enum, random distribution
game/tile/mod.rs TileMeshes resource, tile_shape_system, tile_color_system updated for materials, Tile requires TileShape
game/session/engine.rs shapes channel, Cue struct replaces tuple return
game/session/answer.rs shape field
game/session/mod.rs Shape evaluation + cue generation in round system
game/settings.rs shape toggle (off by default)
game/mod.rs Mesh-based tile spawn, TileMeshes resource init
game/ui/button.rs SameShape action
game/ui/mod.rs Shape button (D key)
menu/ui.rs Shape checkbox in cue grid
menu/checkbox.rs Shape action
debug.rs Shape match + answer display

Keyboard shortcuts (reshuffled to home row)

Key Action
A Position
S Color
D Shape
F Sound

Add a shape cue channel alongside position, color, and sound.
The tile now renders as a 2D mesh (circle, triangle, square,
pentagon, or hexagon) instead of a plain sprite.

Changes:
- New TileShape enum with 5 shape variants + None default
- Tile rendering switched from Sprite to Mesh2d + ColorMaterial
  so the mesh can be swapped per shape
- TileMeshes resource holds pre-built mesh handles for each shape
- CueEngine gains a shapes channel (Option<CueChain<TileShape>>)
- CueEngine::new_cue() returns a Cue struct (cleaner than 4-tuple)
- Answer gains a shape field
- GameSettings gains a shape toggle (off by default)
- Game UI: 4 action buttons (Position A, Color S, Shape D, Sound F)
- Menu UI: shape checkbox in the cue selection grid
- Debug overlay: shape match and shape answer display

Keyboard shortcuts reshuffled to home row:
  A=Position, S=Color, D=Shape, F=Sound
RegularPolygon places its first vertex at the top, producing a
diamond for 4 sides. Rotate the mesh by π/4 to get a flat-edged
square.
RegularPolygon takes a circumradius (center→vertex), but each shape's
bounding box relates differently to that radius. Previously all shapes
used TILE_SIZE/2, making the square ~70% of its expected size.

Now each shape gets its own circumradius computed so the largest
bounding-box dimension equals TILE_SIZE:
  Circle   r = size/2       (bbox = 2r × 2r)
  Triangle r = size/√3      (bbox width = r√3)
  Square   r = size/√2      (bbox = r√2 × r√2 after π/4 rotation)
  Pentagon r = size/(2·sin72°) (bbox width = 2r·sin72°)
  Hexagon  r = size/2       (bbox height = 2r)
@manuelmauro manuelmauro merged commit cc900ef into main Apr 4, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant