feat: prevent reversing directly into snake neck and play denied sound effect

This commit is contained in:
phillip committed 2026-10-01 22:11:00 +02:00
1 parent 60740a53c2
commit fd87ad3091
7 files changed
+89 -19

No files matched your search

+4 -2
View File
@@ -37,7 +37,7 @@ snakePlus/
├── source/ # C++ Implementation files
│ ├── main.cpp # Hardware setup, VBlank IRQ, timer ticks, game bootstrap
│ ├── game_audio.cpp # MaxMod soundbank loading, BGM loop, SFX dispatch
│ ├── game_input.cpp # Key mapping, inverted control logic, menu navigation
│ ├── game_input.cpp # Key mapping, inverted control logic, reverse-denial, menu navigation
│ ├── game_logic.cpp # Position update, edge wrapping, collision resolution, RNG
│ └── game_render.cpp # OAM sprite rendering, console text HUD & menu screens
│
@@ -51,6 +51,7 @@ snakePlus/
│ ├── 273792__pacomav__plop.wav # Movement plop SFX
│ ├── 332629__treasuresounds__item-pickup.wav # Apple pickup SFX
│ ├── Boom.wav # Rotten / Cursed apple boom SFX
│ ├── denied.wav # Reverse-direction denied thud SFX (synthesized)
│ ├── 167126__crisstanza__unpause.wav # Unpause SFX
│ ├── 167127__crisstanza__pause.wav # Pause SFX
│ └── 73750__timbre__remix-of-benboncan-sad-trombone-more-wah-bright-de-clicked.wav # Fail SFX
@@ -95,6 +96,7 @@ The game operates in one of two scenes ([`Scene`](include/game_state.h#L9-L12)):
- **Normal Apple (Red):** Spawns if count < 1. Awards +10 score, increases length by 1, plays pickup sound. Flashes/blinks every 4 ticks.
- **Rotten Apple (Brown/Green):** Spawns in Hard Mode (periodic chance up to 20 on screen). Decreases length by 1, plays explosion SFX. If length drops below 2, triggers Game Over.
- **Cursed Apple (Purple):** Spawns occasionally. Inverts player steering controls (Up ↔ Down, Left ↔ Right) for `CURSE_DURATION_TICKS` (40 ticks). The sprite is procedurally constructed at startup in [`main.cpp:91-112`](source/main.cpp#L91-L112) by copying the rotten apple tile pixels and mapping them to dedicated palette entries (`CURSE_PAL_SHADOW`, `CURSE_PAL_OUTLINE`, `CURSE_PAL_FILL`, `CURSE_PAL_GLOW`).
- **Reverse-Direction Denial:** Pressing the D-Pad in the exact opposite direction (i.e. into the snake's own neck) is silently denied instead of causing an immediate Game Over. The game computes the would-be next head position (including edge-wrapping) and compares it to the neck segment; if they match, the direction change is rejected and a subtle "denied" thud SFX plays.
### 3.4 Game Modes
- **Normal Mode:** Starts with length 4, timer frequency `TIMER_FREQ_1024(5)`, background color `RGB15(5,5,5)`.
@@ -108,7 +110,7 @@ The game operates in one of two scenes ([`Scene`](include/game_state.h#L9-L12)):
|---|---|---|
| **Menu** | D-Pad Up / Down | Change selected menu item |
| **Menu** | A / START | Select / Toggle option / Start game |
| **Playing** | D-Pad | Steer snake (inverted if cursed) |
| **Playing** | D-Pad | Steer snake (inverted if cursed; reversing into neck is denied with subtle SFX) |
| **Playing** | START | Pause / Unpause |
| **Playing** | R | Swap LCD displays (`lcdSwap()`) |
| **Playing** | SELECT | Toggle debug internals HUD overlay |