robotoFont
p5.Font
Stores the loaded Roboto font for consistent text rendering across all screens
let robotoFont;
particles
array
Array of floating particle objects that drift upward in the background for visual ambiance
let particles = [];
step
number
Tracks the current instruction panel index (0–9) for the welcome screen
let step = 0;
stepTimer
number
Counts frames since the current instruction panel appeared; resets when exceeding stepDuration
let stepTimer = 0;
stepDuration
number
Number of frames each instruction panel stays visible before auto-advancing (225 frames ≈ 3.75 seconds)
let stepDuration = 225;
instructions
array
Array of 10 instruction objects, each with title and description for the welcome carousel
let instructions = [{title: "...", desc: "..."}, ...];
p1
object
Player 1 object containing position (x, y), size, color, stamina, trail, and speed
let p1 = {x: 50, y: 50, size: 30, color: [255, 0, 0], stamina: 100, trail: [], speed: 4};
p2
object
Player 2 object (blue), only used in two-player mode; similar structure to p1
let p2 = {x: 50, y: 520, size: 30, color: [0, 150, 255], stamina: 100, trail: [], speed: 4};
enemies
array
Array of enemy objects, each with x, y, and size; count increases at higher levels
let enemies = [];
goal
object
The exit/win zone at position (x, y) with a size; becomes visible only after all coins are collected
let goal = {x: 720, y: 50, size: 40};
walls
array
Array of obstacle rectangles with x, y, width, and height; randomly generated each level
let walls = [];
coins
array
Array of coin objects at position (x, y) with active status; must collect all 3 to unlock the goal
let coins = [];
level
number
Current level number (1–10); determines number of walls, enemy count, enemy speed, and time limit
let level = 1;
lives
number
Remaining lives; game ends when lives reach 0
let lives = 3;
wallet
number
Total money earned from collecting coins; spent in the shop on upgrades
let wallet = 0;
timer
number
Remaining time in seconds for the current level; player dies if timer reaches 0
let timer = 30;
enemySpeed
number
Speed at which enemies chase the player; increases with level difficulty
let enemySpeed = 2;
lightRadius
number
Radius in pixels of the circular light zone around each player; increased by the flashlight upgrade
let lightRadius = 160;
gameState
string
Current game screen: 'MENU', 'HOWTO', 'PLAYING', 'SHOP', 'WINNER', or 'GAMEOVER'
let gameState = 'MENU';
playerMode
number
Game mode: 1 for single-player, 2 for two-player cooperative
let playerMode = 1;
winTriggered
boolean
Flag to prevent the win condition from firing multiple times in a single level
let winTriggered = false;