gameMode
string
Stores the current game mode ('classic', 'turbo', 'boss', 'mini', 'giant', 'gravity', 'portal', 'reverse', 'sniper', 'mayhem', 'blackhole'). Controls which rules and physics apply.
let gameMode = 'classic';
isRunning
boolean
True when the game is actively playing; false when paused. Controls whether ball and bullet physics update.
let isRunning = false;
isSinglePlayer
boolean
True in 1P mode (P1 vs AI); false in 2P mode (P1 vs P2). Controls paddle input and AI behavior.
let isSinglePlayer = false;
ballX, ballY, ballVX, ballVY
number
Ball position (X, Y) and velocity (VX, VY in pixels per frame). Updated every frame to create animation.
let ballX = width / 2; let ballVY = 0;
ballSize, ballSpeed
number
Ball radius and base movement speed. Scaled per mode.
let ballSize = 15; let ballSpeed = 3;
leftX, leftY, rightX, rightY
number
Paddle positions. Left paddle is player 1; right paddle is player 2 (or AI in 1P).
let leftX = 20; let rightY = height / 2;
paddleW, paddleH, paddleSpeed
number
Paddle width, height, and movement speed per frame. Scaled per mode.
let paddleH = 80; let paddleSpeed = 2;
p1Score, p2Score
number
Current score for players 1 and 2. Incremented when opponent fails to defend.
let p1Score = 0;
p1Coins, p2Coins
number
Earned currency. Incremented by scoring and damaging bosses. Spent to upgrade guns.
let p1Coins = 0;
p1GunLevel, p2GunLevel
number
Gun upgrade level (0 = no gun, 1–3 = levels). Controls bullet speed and cooldown.
let p1GunLevel = 0;
p1ShootCooldown, p2ShootCooldown
number
Countdown frames until the next shot is allowed. Decremented each frame; blocks shooting when > 0.
let p1ShootCooldown = 0;
bullets
array
Array of bullet objects {x, y, vx, vy, r, owner}. Updated and drawn every frame.
let bullets = [];
boss1, boss2
object
Boss objects {x, y, w, h, hp, col} in boss modes. Null in normal modes.
let boss1 = null; // {x: 50, y: 300, w: 20, h: 400, hp: 10, col: blue}
bossMaxHP
number
Maximum health for each boss. Used to calculate health bar width.
let bossMaxHP = 10;
bossFightOver
boolean
True when a boss fight ends (a boss reaches 0 HP). Prevents further gameplay until reset.
let bossFightOver = false;
modeGravity
number
Vertical acceleration in Gravity mode. Added to ballVY each frame. 0 in other modes.
let modeGravity = 0.2;
modeVerticalWrap
boolean
True in Portal mode; makes ball wrap to opposite vertical edge instead of bouncing.
let modeVerticalWrap = false;
modeReverseControls
boolean
True in Reverse mode; flips paddle direction (W becomes down, S becomes up).
let modeReverseControls = false;
blackHoleX, blackHoleY, blackHoleRadius
number
Position and size of the central gravity well in Black Hole mode. Zero when inactive.
let blackHoleX = width / 2; let blackHoleRadius = 50;
blackHoleStrengthBall, blackHoleStrengthBullet
number
Gravity force magnitude for ball and bullets in Black Hole mode. Higher = stronger pull.
let blackHoleStrengthBall = 300;
isShopOpen
boolean
True when the gun shop is displayed. Pauses the game and blocks normal input.
let isShopOpen = false;
currentLevel
number
Current level in 1P mode (1, 2, 3, ...). Incremented on victory; decremented on defeat.
let currentLevel = 1;