gameState
string
Tracks which screen/mode the game is in: 'hub' (world select), 'level' (gameplay), 'boss' (boss fight), or 'win' (victory screen)
let gameState = 'hub';
currentWorld
number
Stores which world (0-4) the player is currently in or preparing to enter
let currentWorld = 0;
player
object
An object containing all player data: position (x, y), velocity (vx, vy), size, animation state, and action timers (punching, spinning, invincible)
let player = { x: 200, y: 300, vx: 0, vy: 0, w: 30, h: 40, onGround: false, ... };
platforms
array
An array of platform objects; each platform has x, y, width, and height for collision detection
let platforms = [ { x: 0, y: 450, w: 800, h: 50 }, ... ];
enemies
array
An array of enemy objects; each enemy has x, y, velocity, size, alive status, and type
let enemies = [ { x: 300, y: 400, vx: 1.5, w: 25, h: 25, alive: true, type: 0 }, ... ];
bots
array
An array of bot objects to rescue; each bot has x, y, rescued status, and animation offset
let bots = [ { x: 400, y: 200, rescued: false, bobOffset: 1.5 }, ... ];
boss
object or null
The current boss object (if any); contains position, size, velocity, phase, health, and visual data
let boss = { x: 600, y: 300, w: 80, h: 80, vx: 2, phase: 0, ... };
score
number
The player's accumulated score, increased by defeating enemies (100 points) and rescuing bots (500 points)
let score = 0;
lives
number
The number of lives the player has remaining; starts at 3, decreases when hit or falling off screen
let lives = 3;
botsRescued
number
Total count of bots rescued across all levels; displayed in the hub and win screen
let botsRescued = 0;
bossHealth
number
The current health of the active boss (decreases when hit); when it reaches 0, the boss is defeated
let bossHealth = 0;
bossMaxHealth
number
The maximum health of a boss (100 points); used to calculate the health bar ratio
let bossMaxHealth = 100;
particles
array
An array of particle objects for visual effects (explosions, sparks); each particle has position, velocity, life, color, and size
let particles = [ { x: 200, y: 150, vx: -2, vy: -4, life: 30, color: [255, 200, 0], size: 5 }, ... ];
stars
array
An array of star objects for the parallax background; each star has x, y, size (s), and scroll speed (sp)
let stars = [ { x: 100, y: 50, s: 2, sp: 1.2 }, ... ];
shakeAmount
number
Controls screen shake intensity; decreases each frame to create a fading shake effect after impacts or explosions
let shakeAmount = 0;
joystick
object
The on-screen joystick control; stores position (x, y), radius (r), and normalized input (dx, dy)
let joystick = { x: 100, y: 500, r: 50, dx: 0, dy: 0, active: false };
jumpBtn
object
The jump button object; stores position and radius for hit detection
let jumpBtn = { x: 700, y: 500, r: 35, label: '↑' };
punchBtn
object
The punch button object; stores position and radius for hit detection
let punchBtn = { x: 750, y: 430, r: 35, label: '👊' };
spinBtn
object
The spin button object; stores position and radius for hit detection
let spinBtn = { x: 750, y: 500, r: 35, label: '🌀' };
WORLDS
array of objects
A constant array defining the five worlds; each world has a name, color, boss name, boss color, and background color
const WORLDS = [ { name: 'Jungle Planet', color: [40, 180, 60], boss: 'Rilla', ... }, ... ];