Skip to main content

Overview

ScoreManager is a global autoload singleton that persists all player data including:
  • High scores for each minigame
  • Coin balance
  • Inventory items (shells and accessories)
  • Equipped cosmetic items
All data is automatically saved to user://high_scores.cfg using Godot’s ConfigFile system.

Signals

skin_updated
signal
Emitted when the player equips a new shell or accessory. Used by the character visual and store UI to update appearances.

Coin Management

add_coins()

Adds coins to the player’s balance and saves to disk.
amount
int
required
Number of coins to add (can be positive or negative)
return
void
No return value
Example Usage:
# Award coins after completing a minigame
ScoreManager.add_coins(50)

# From turtle_run/main.gd:118
ScoreManager.add_coins(coins_earned)

get_coins()

Retrieve the player’s current coin balance.
return
int
Current number of coins
Example Usage:
# Display coins in UI
var current_coins = ScoreManager.get_coins()
coin_label.text = str(current_coins)

# From main_menu.gd:277
var current_coins = ScoreManager.get_coins()
coin_label.text = format_number(current_coins)

Inventory Management

add_to_inventory()

Adds an item to the player’s inventory if not already owned. Automatically saves to disk.
item_name
String
required
Name of the item to add (e.g., “Caparazón Azul”, “Corona”)
return
void
No return value
Example Usage:
# Add item after purchase
ScoreManager.add_to_inventory("Caparazón Verde")
ScoreManager.add_to_inventory("Corona")

get_inventory()

Returns the player’s full inventory as an array of item names.
return
Array
Array of String item names owned by the player
Example Usage:
# Check if player owns an item
var inventory = ScoreManager.get_inventory()
if inventory.has("Gafas"):
    print("Player owns sunglasses!")

equip_item()

Equips an item from inventory. Emits skin_updated signal to refresh character visuals.
category
String
required
Equipment slot: either "caparazon" (shell) or "accesorio" (accessory)
item_name
String
required
Name of item to equip, or "default"/"none" for default appearance
return
void
No return value
Example Usage:
# Equip a blue shell
ScoreManager.equip_item("caparazon", "Caparazón Azul")

# Equip a crown accessory
ScoreManager.equip_item("accesorio", "Corona")

# Remove accessory
ScoreManager.equip_item("accesorio", "none")

get_equipped_item()

Returns the currently equipped item for a category.
category
String
required
Equipment slot: "caparazon" or "accesorio"
return
String
Name of currently equipped item, or "none"/"default" if nothing equipped
Example Usage:
# Get current shell
var current_shell = ScoreManager.get_equipped_item("caparazon")

# From main_menu.gd:99-100
var id_cuerpo = ScoreManager.get_equipped_item("caparazon")
var id_accesorio = ScoreManager.get_equipped_item("accesorio")

is_equipped()

Checks if a specific item is currently equipped in either slot.
item_name
String
required
Item name to check
return
bool
true if the item is equipped, false otherwise
Example Usage:
# Show checkmark in store UI
if ScoreManager.is_equipped("Caparazón Azul"):
    checkmark.visible = true

High Score Management

save_high_score()

Saves a new high score if it beats the current record.
game_name
String
required
Minigame identifier: "memorice", "turtle_runner", "worm_catch", "food_catch", "counting_animals", or "nyuron_color"
new_score
int
required
Score to save
return
bool
true if new score beats the old record, false otherwise
Example Usage:
# Save score at end of minigame
var beat_record = ScoreManager.save_high_score("turtle_runner", final_score)
if beat_record:
    show_new_record_popup()

# From turtle_run/main.gd:116-117
var is_new_record = ScoreManager.save_high_score("turtle_runner", score)
ScoreManager.add_coins(coins_earned)

get_high_score()

Retrieves the current high score for a minigame.
game_name
String
required
Minigame identifier
return
int
High score for the game, or 0 if game not found
Example Usage:
# Display high score in menu
var best_score = ScoreManager.get_high_score("memorice")
high_score_label.text = "Best: " + str(best_score)

get_all_scores()

Returns a dictionary containing all high scores.
return
Dictionary
Dictionary with game names as keys and high scores as values
Example Usage:
# Show all scores in progress panel
var scores = ScoreManager.get_all_scores()
for game_name in scores:
    print(game_name, ": ", scores[game_name])

Persistence Methods

load_high_scores()

Loads all player data from disk. Called automatically in _ready().
return
void
No return value
Note: Creates a new save file if none exists.

save_to_file()

Writes all current data to disk. Called automatically by methods that modify data.
return
void
No return value

Data Structure

high_scores Dictionary

{
    "memorice": 0,
    "turtle_runner": 0,
    "worm_catch": 0,
    "food_catch": 0,
    "counting_animals": 0,
    "nyuron_color": 0
}

equipped_items Dictionary

{
    "caparazon": "default",  # Shell/body color
    "accesorio": "none"      # Hat, glasses, etc.
}

Save File Location

const SAVE_PATH = "user://high_scores.cfg"

Complete Example

# End-of-game flow in a minigame
func on_game_over(final_score: int, coins_collected: int):
    # Save high score
    var is_new_record = ScoreManager.save_high_score("turtle_runner", final_score)
    
    # Award coins
    ScoreManager.add_coins(coins_collected)
    
    # Show results
    if is_new_record:
        show_new_record_banner()
    
    # Display updated coin count
    coin_label.text = str(ScoreManager.get_coins())

Build docs developers (and LLMs) love