Overview
The Nyuron Color minigame is a Simon-style sequence memory game where players must replicate increasingly longer color sequences. This script manages the Simon game logic, sequence generation, and player input validation. Script Path:minigames/nyuron_color/scripts/main.gd
Extends: Node2D
Exported Variables
None - all configuration is handled through scene setup and constants.@onready Node References
Crabs (Interactive Elements)
Dictionary mapping color names to crab node references:
"red": $Crabs/CrabRed"blue": $Crabs/CrabBlue"green": $Crabs/CrabGreen"yellow": $Crabs/CrabYellow
UI Elements
Displays current score (sequence length achieved)
Shows game state messages: “Observa…”, “Tu turno”, “Bien hecho!”
Initial instruction panel shown before game starts
Button to start the game from intro panel
Pause button visible during gameplay
Game Over Panel
Game over/pause overlay panel
Panel title (“Fallaste” or “Pausa”)
Final score display in game over panel
Return to main menu button
Restart game button
State Variables
The current color sequence the player must replicate. Grows by one color each successful round.Example:
["red", "blue", "red", "yellow"]Player’s current input sequence. Cleared at the start of each round.
Available colors for sequence generation:
["red", "blue", "green", "yellow"]Whether the game is currently showing the sequence to the player (blocks input)
Whether the player’s turn has begun (enables crab input)
Debounce flag to prevent rapid double-taps on crabs
Whether the game is paused
Coins earned in the current session (for display in game over)
Signals
Emitted when player navigates back to main menu from pause
Core Functions
Game Initialization
Initializes the game:
- Sets screen to portrait 270x480
- Hides game UI elements
- Connects crab press signals
- Shows intro panel
Starts the game when intro button is pressed. Hides intro panel and begins first round.
Game Flow
Resets game state and starts a new game:
- Clears sequence and player input
- Resets score to 0
- Adds first color to sequence
- Plays the sequence
Adds a random color to the sequence.
Shows the current sequence to the player by flashing each crab in order.Behavior:
- Blocks player input during sequence display
- Flashes each crab with 0.6s delay between colors
- Sets
game_started = truewhen finished - Updates info label to “Tu turno”
Player Input
Called when player taps a crab. Validates input against expected sequence.Parameters:
color(String): Color of the tapped crab
- Ignores input if game is paused, showing sequence, or processing previous input
- Uses
is_processing_inputflag to prevent double-taps (0.1s debounce) - Checks if color matches expected position in sequence
- Calls
_game_over()if wrong color - Calls
_next_round()if sequence completed correctly
Advances to next round after successful sequence completion.Behavior:
- Updates score display to current sequence length
- Shows “Bien hecho!” message
- Waits 1 second
- Adds new color to sequence
- Plays updated sequence
Game Over
Called when player makes a mistake. Saves score and shows game over panel.Scoring:
- Final score = sequence length achieved
- Coins earned = sequence length × 20
Navigation
Returns to main menu. Resets screen orientation to portrait.
Reloads the current scene to restart the game.
Toggles pause state when back button pressed during gameplay.
Pause System
Pauses the game:
- Sets
is_paused = true - Blocks sequence display and player input
- Disables crab input
- Pauses crab animations
- Shows pause panel
Resumes from pause:
- Sets
is_paused = false - Re-enables crab input if not showing sequence
- Resumes crab animations
- Hides pause panel
Scene Structure Requirements
The scene must include:- Four crab nodes under
$Crabs/(CrabRed, CrabBlue, CrabGreen, CrabYellow) - Each crab must emit
crab_pressed(color: String)signal and have_flash()method - UI labels for score and info
- Intro panel with start button
- Game over panel with title, score, back, and retry buttons
- Back button for pause during gameplay
Related Documentation
Nyuron Color Guide
User guide for the Nyuron Color minigame
ScoreManager API
High score and coin management system