gameState
string
Tracks which screen/mode the app is in (SPLASH, HOME, PLAYING, PAUSED, GAMEOVER, etc.) and drives the switch statement in draw().
let gameState = 'SPLASH';
gameMode
string
Stores which gameplay mode was selected (FREEPLAY, CAREER, DRIFT_BATTLE, etc.).
let gameMode = 'FREEPLAY';
difficulty
string
Stores the selected difficulty level, intended to scale AI toughness.
let difficulty = 'NORMAL';
player
object
Holds the player's Vehicle instance, created when a run starts.
let player;
players
array
Reserved array for multiple player Vehicles in a future multiplayer mode.
let players = [];
cam
object
The Camera instance that computes and applies the 3D view every frame.
let cam;
cameraMode
string
Which camera view is active (CHASE, HOOD, BUMPER, ORBIT); cycled with the 'c' key.
let cameraMode = 'CHASE';
worldTime
number
The in-game clock in minutes (0-1440), driving sky color, lighting, and headlights.
let worldTime = 720;
weather
string
Current weather type (CLEAR, RAIN, SNOW, FOG, STORM) affecting visuals and fog overlay.
let weather = 'CLEAR';
weatherIntensity
number
A 0-1 strength value used to scale fog opacity and rain density.
let weatherIntensity = 0;
temperature
number
A Fahrenheit temperature value tracked for flavor/future features.
let temperature = 72;
season
string
Current season name, reserved for future seasonal visual changes.
let season = 'SUMMER';
traffic
array
Holds all AI traffic Vehicle instances currently active in the world.
let traffic = [];
cops
array
Holds all active police Vehicle instances chasing the player.
let cops = [];
helicopters
array
Reserved array for future helicopter pursuit units.
let helicopters = [];
roadblocks
array
Holds roadblock obstacle objects that get displayed during a chase.
let roadblocks = [];
spikeStrips
array
Holds spike-strip obstacle objects intended to slow the player down.
let spikeStrips = [];
playerData
object
The player's persistent profile - cash, level, XP, owned cars, and stats - loaded/saved via localStorage.
let playerData = { cash: 50000, level: 1, xp: 0 };
wantedLevel
number
How many wanted stars (0-5) the player currently has, controlling cop spawning.
let wantedLevel = 0;
heatLevel
number
A 0-100 meter that rises when cops see the player and decays otherwise, eventually dropping the wanted level.
let heatLevel = 0;
escapeZones
array
Reserved array for special zones where the player could shake a police chase.
let escapeZones = [];
cooldownTimer
number
A reserved timer variable, intended to gate how often certain actions can repeat.
let cooldownTimer = 0;
skidmarks
array
Stores tire skid mark objects (position + remaining life) drawn on the ground during drifts.
let skidmarks = [];
particles
array
The universal particle array used for smoke, nitro flames, and explosions.
let particles = [];
debris
array
Reserved array for crash debris particles/objects.
let debris = [];
raindrops
array
Stores active raindrop objects during RAIN weather.
let raindrops = [];
snowflakes
array
Reserved array for snow particles during SNOW weather (not yet rendered).
let snowflakes = [];
audioEngine
object
The AudioSystem instance managing the procedural engine sound.
let audioEngine;
musicTracks
object
Reserved object intended to hold background music track references.
let musicTracks = {};
soundEffects
object
Reserved object intended to hold sound effect clip references.
let soundEffects = {};
notifications
array
Holds temporary on-screen messages (like drift point payouts) with a countdown life.
let notifications = [];
driftScore
number
The current, still-active drift combo's accumulated score before it's banked as cash.
let driftScore = 0;
driftCombo
number
The current combo multiplier (grows while drifting, capped at 10) applied to drift scoring.
let driftCombo = 0;
comboTimer
number
A countdown grace period that keeps the drift combo alive briefly after drifting stops.
let comboTimer = 0;
speedText
string
A cached text string for displaying speed (declared but superseded by direct text() calls in renderHUD).
let speedText = "0 MPH";
minimap
object
The Minimap instance, currently a stub with an empty display() method.
let minimap;
controls
object
Boolean flags (gas, brake, left, right, handbrake, nitro, horn) reflecting which keyboard controls are currently held down.
let controls = { gas: false, brake: false };
touchControls
object
Boolean flags for on-screen mobile touch buttons (up, down, left, right).
let touchControls = { up: false, down: false, left: false, right: false };
gyroEnabled
boolean
Whether gyroscope/tilt steering is currently enabled.
let gyroEnabled = false;
gyroTilt
number
The device's current left-right tilt angle from deviceorientation events, used for gyro steering.
let gyroTilt = 0;
CAR_SPECS
object
A constant database of every car's stats (speed, acceleration, handling, drift, color, price) keyed by car type.
const CAR_SPECS = { STARTER: { name: "Street Racer", maxSpeed: 140 } };