Overview
The Worm Bucket minigame is a time-based catching game where players shoot a claw to catch worms before time runs out. Bad worms cause stuns, and captured worms can escape from the bucket. Script Path:minigames/worm_bucket/scripts/main.gd
Extends: Node2D
Exported Variables
None - all configuration is handled through scene references and constants.@onready Node References
UI Elements
Displays current score (worms caught)
Displays remaining time in seconds (formatted as “XX.XX s”)
Initial instruction panel
Start game button in intro panel
Pause button during gameplay
Game Over Panel
Game over/pause overlay
Panel title (“Fin del Juego” or “Pausa”)
Final score in game over panel
Return to main menu button
Restart game button
Game Objects
60-second countdown timer. Triggers
_on_game_over() when it reaches zero.Periodic timer that triggers worm escapes from bucket. Fires every few seconds.
The Nyuron character node with claw shooting mechanics
Worm spawner that emits
spawned signal when creating new wormsThe bucket where caught worms are stored
Animated sprite showing bucket fill states (0-5+ worms)
Red border overlay for visual feedback when hitting bad worms
Shader material for damage pulse effect
Audio
Sound effect played when catching a worm (pitch varies 0.9-1.1)
Sound effect played when catching a bad worm
State Variables
Current score (number of worms caught). Decreases by 1 when a worm fully escapes.
Number of worms currently in the bucket. Affects bucket sprite animation.
Whether player is currently stunned (from catching bad worm). Blocks input for 2 seconds.
Whether game is paused
Coins earned in current session (for game over display)
Reference to the damage pulse animation tween
Signals
Emitted when navigating back to main menu
Core Functions
Game Initialization
Initializes the game:
- Connects spawner, timer, and button signals
- Sets up UI process modes for pause handling
- Adds self to “worm_game” group
- Shows intro panel
Shows intro panel and pauses all game systems:
- Sets
is_paused = true - Pauses game_timer, escape_timer, and spawner
- Disables worm input
- Hides back button
Starts the game when intro button pressed:
- Hides intro panel
- Sets
is_paused = false - Unpauses all timers
- Enables worm input
- Starts 60-second countdown
Main Loop
Updates timer display each frame:
Spawner Integration
Called when spawner creates a new worm. Sets up worm connections.Parameters:
worm(Node): The spawned worm instance
- Assigns
gamereference to worm - Connects
request_catchandescapedsignals - Connects
input_eventfor click detection - Sets
input_pickable = true
Handles mouse clicks on worms. Calls
_on_worm_request_catch() when left-clicked.Parameters:_viewport(Viewport)event(InputEvent)_shape_idx(int)worm(Node)
Worm Escape System
Called periodically to make worms escape from bucket:
- Decreases
bucket_countby 1 (min 0) - Spawns escaped worm with
start_escape()behavior - Worm starts at bucket position and swims away
Worm Catching
Main catch logic triggered when player clicks a worm.Parameters:
worm(Node): The worm being caught
- Checks
worm.is_badproperty - Plays fail sound
- Sets
is_stunned = truefor 2 seconds - Calls
nyuron.stun(2.0) - Starts damage pulse visual effect
- Removes worm from scene
- Calls
nyuron.shoot_to(worm_position, is_recapture) is_recaptureistrueif worm state is “ESCAPING”- Waits for
claw_reached_targetsignal - Attaches worm to claw tip
- Waits for
shot_finishedsignal - Calls
worm.detach_and_go_to_bucket() - Increments
scoreby 1 (only if not recapture) - Increments
bucket_countby 1 - Plays catch sound with pitch variation
Called when a worm fully escapes off-screen:
- Decreases score by 1 (min 0)
- Updates UI
- Prints escape message
_worm(Node): The escaped worm
Game Over
Called when 60-second timer expires:
- Stops spawner and escape timer
- Updates time label to “Fin. Puntos: X”
- Saves high score via ScoreManager
- Calculates coins:
score × 2.5 - Disables all worm input
- Shows game over panel
Displays the game over panel with final score and coins earned.
Navigation
Returns to main menu. Resumes game if paused first.
Reloads current scene to restart game.
Toggles pause when back button pressed during gameplay.
UI Updates
Updates score label and bucket sprite animation:Bucket States:
- 0 worms: “balde vacio”
- 1 worm: “con 1 gusano”
- 2 worms: “con 2 gusano”
- 3 worms: “con 3 gusano”
- 4 worms: “con 4 gusano”
- 5+ worms: “balde lleno”
Visual Effects
Starts looping red border pulse effect when bad worm is caught:
- Tweens shader intensity 0.0 → 0.4 → 0.0
- Loop continues until
_stop_damage_pulse()called - 0.2s per pulse phase
Stops damage pulse tween and resets shader intensity to 0.0
Pause System
Pauses the game:
- Pauses game_timer and escape_timer
- Pauses spawner timer
- Disables Nyuron processing and animation
- Calls
pause_all_worms(true) - Stops bucket sprite animation
- Kills damage tween if active
- Shows game over panel with “Pausa” title
Resumes from pause:
- Unpauses all timers
- Re-enables Nyuron and worms
- Resumes animations
- Hides game over panel
Helper to pause/unpause all worms in Playfield.Parameters:
pause(bool): Iftrue, disables worm processing and sets animation speed to 0.0. Iffalse, re-enables.
Scene Structure Requirements
The scene must include:- Nyuron character node with
shoot_to(),stun()methods andclaw_reached_target,shot_finishedsignals - Spawner node with
spawnedsignal andworm_sceneproperty - Bucket node (Node2D) with animated sprite showing fill states
- Playfield node (container for spawned worms)
- UI elements: score label, timer label, damage border with shader
- Game timer (60s) and escape timer
- Intro and game over panels
Related Documentation
Worm Bucket Guide
User guide for the Worm Bucket minigame
ScoreManager API
High score and coin management system