feat: add shape cues as a new stimulus channel#6
Merged
Conversation
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)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
SpritetoMesh2d+MeshMaterial2d<ColorMaterial>:Mesh2dhandle (from aTileMeshesresource with pre-built handles)ColorMaterialassetNew/modified files
game/tile/shape.rsTileShapeenum, random distributiongame/tile/mod.rsTileMeshesresource,tile_shape_system,tile_color_systemupdated for materials,TilerequiresTileShapegame/session/engine.rsshapeschannel,Cuestruct replaces tuple returngame/session/answer.rsshapefieldgame/session/mod.rsgame/settings.rsshapetoggle (off by default)game/mod.rsTileMeshesresource initgame/ui/button.rsSameShapeactiongame/ui/mod.rsmenu/ui.rsmenu/checkbox.rsShapeactiondebug.rsKeyboard shortcuts (reshuffled to home row)