tileSize
number
Size of ground tiles in world units; controls the scale of the landscape
let tileSize = 200;
playerX, playerY, playerZ
number
The player's 3D position in world space
let playerX = 0; let playerY = -35; let playerZ = 0;
playerHeading
number
The angle (in radians) the player is facing; 0 = facing +Z direction
let playerHeading = 0;
moveSpeed
number
How many world units the player moves per frame when walking
let moveSpeed = 4;
turnSpeed
number
How many radians the player rotates per frame when turning
let turnSpeed = 0.04;
treasureCellX, treasureCellZ
number
The tile coordinates (grid index) where the treasure is buried
let treasureCellX, treasureCellZ;
treasureX, treasureZ
number
The world coordinates of the treasure location (cellX/Z multiplied by tileSize)
let treasureX, treasureZ;
isDigging
boolean
True if the player is currently holding SPACE and digging
let isDigging = false;
digProgress
number
A value from 0 to 1 indicating how far the digging animation has progressed
let digProgress = 0;
treasureFound
boolean
True once the player has successfully dug up the treasure
let treasureFound = false;
treasureRise
number
A value from 0 to 1 controlling how high the treasure has risen after being found
let treasureRise = 0;
treasureImg
p5.Image
The loaded treasure image (or undefined if loading failed)
let treasureImg;
treasureImgLoaded
boolean
True once the treasure image has finished loading
let treasureImgLoaded = false;
treasureImgFailed
boolean
True if the treasure image failed to load from the URL
let treasureImgFailed = false;
hudFont
p5.Font
The font object loaded for rendering HUD text in WEBGL
let hudFont;
lastDistToTreasure
number
Cached distance from player to treasure, updated each frame for HUD display
let lastDistToTreasure = 0;
lastRelAngle
number
The angle from the player's heading to the treasure (in radians), used for compass hints
let lastRelAngle = 0;