Skip to main content

Snowbirdgamescreen

Based on game build 714014 | Last updated: 2026-03-09

Overview

SnowbirdGameScreen is a specialized Screen subclass that implements a tile-matching mini-game where players flip and match tiles to gain score and preserve lives. It handles UI construction, game state transitions, tile animation/movement, scoring, and server-side reporting for reward distribution. It uses MiniGameTile, UIAnim, and SkinCollector components, and depends on stats.lua for metrics reporting. The screen supports both keyboard/mouse and controller input.

Usage example

local SnowbirdGameScreen = require "screens/snowbirdgamescreen"
local profile = ThePlayer and ThePlayer.components.playerprofile or nil
local screen = SnowbirdGameScreen(profile)
TheFrontEnd:PushScreen(screen)

Dependencies & tags

Components used: uianim, stats Tags: Checks debuffed, buffed, depleted via MiniGameTile; manages internal exploded flags per tile.

Properties

PropertyTypeDefault ValueDescription
profiletablenilPlayer profile object used to read/write high scores.
scorenumber0Current game score.
livesnumber3Remaining player lives.
game_statenumberGS_GAME_OVEROne of the GS_* constants (06) indicating the current game phase.
game_gridtablenilArray of 6 MiniGameTile widgets, arranged 2 rows × 3 columns.
startbuttonTextButtonnilButton widget to restart/reset the board.
resetbuttonTextButtonnilButton widget to start a new round.
innkeeperSkinCollectornilNPC speech/sfx provider during gameplay.

Main functions

InitGameBoard()

  • Description: Resets score/lives, clears and reshuffles the game grid, and initiates tile-filling animations. Only runs if the game is not already in the dropping state.
  • Parameters: None.
  • Returns: Nothing.

OnTileClick(x, y)

  • Description: Handles player tile selection/tile-flipping logic. Validates game-state transitions (reviewing → tile selection 1 → transition → tile selection 2 → clearing). Handles match detection, scoring, life changes, tile explosion FX, and queued input.
  • Parameters:
    • x (number) – Column index (02).
    • y (number) – Row index (01).
  • Returns: Nothing.

UpdateInterface()

  • Description: Updates UI text (score, lives, high score) and manages button states. Triggers game-over logic (including Stats.PushMetricsEvent, ReportSnowbirdGame, and reward popups) when lives == 0.
  • Parameters: None.
  • Returns: Nothing.

ExplodeTile(explode_delay, tile)

  • Description: Triggers visual and audio FX for a matched tile: plays takeoff sound for snowbird tiles, or flip sound with explosion FX for others. Clears the tile after delay.
  • Parameters:
    • explode_delay (number) – Delay before clearing the tile.
    • tile (MiniGameTile) – Tile to explode.
  • Returns: Nothing.

DropTiles()

  • Description: Moves tiles downward to fill empty grid positions, using hidden mover tiles for animation.
  • Parameters: None.
  • Returns: Nothing.

FillEmptyTiles(allow_dupes)

  • Description: Generates and drops new tiles into empty grid slots from a shuffled list of TILE_TYPES. Supports optional duplicate prevention.
  • Parameters:
    • allow_dupes (boolean) – Whether to allow the same tile type to be dropped multiple times in a column.
  • Returns: Nothing.

Quit()

  • Description: Shuts down the screen cleanly: clears NPC speech, stops joystick listeners, kills all mover widgets, and triggers screen fade-out.
  • Parameters: None.
  • Returns: Nothing.

Events & listeners

  • Listens to: control events via OnControl, including CONTROL_ACCEPT, CONTROL_CANCEL, CONTROL_MENU_MISC_1, CONTROL_MENU_START, and CONTROL_MENU_MISC_2.
  • Pushes: buffed, debuffed, depleted events via the underlying MiniGameTile widgets.