gameState
string
Controls which screen is displayed and what logic runs each frame—values are 'start', 'playing', or 'gameOver'
let gameState = 'start';
SPIDERMAN_SIZE
number
The diameter of Spider-Man's circular body in pixels—used for collision detection and display sizing
const SPIDERMAN_SIZE = 50;
SPIDERMAN_SPEED
number
How many pixels Spider-Man moves per frame with each arrow key press—controls left/right responsiveness
const SPIDERMAN_SPEED = 4;
SPIDERMAN_JUMP_FORCE
number
Initial upward velocity applied when jumping—determines jump height
const SPIDERMAN_JUMP_FORCE = 15;
SPIDERMAN_HEALTH
number
Spider-Man's starting health points—game ends when this reaches 0
const SPIDERMAN_HEALTH = 100;
SPIDERMAN_ATTACK_DAMAGE
number
Health points removed from an enemy per successful Spider-Man attack
const SPIDERMAN_ATTACK_DAMAGE = 10;
SPIDERMAN_ATTACK_RANGE
number
How close Spider-Man must be to a target to deal damage—measured in pixels
const SPIDERMAN_ATTACK_RANGE = 60;
DEADPOOL_SIZE
number
The diameter of Deadpool's circular body in pixels
const DEADPOOL_SIZE = 50;
DEADPOOL_SPEED
number
How many pixels Deadpool moves per frame toward Spider-Man—controls AI speed
const DEADPOOL_SPEED = 2;
DEADPOOL_HEALTH
number
Deadpool's starting health points—beating the game requires reducing this to 0
const DEADPOOL_HEALTH = 120;
DEADPOOL_ATTACK_DAMAGE
number
Health points removed from Spider-Man per successful Deadpool attack
const DEADPOOL_ATTACK_DAMAGE = 15;
DEADPOOL_ATTACK_RANGE
number
How close Deadpool must be to Spider-Man to attack automatically—measured in pixels
const DEADPOOL_ATTACK_RANGE = 70;
GRAVITY
number
Acceleration applied to characters each frame—simulates Earth's gravity pulling them downward
const GRAVITY = 0.6;
GROUND_LEVEL
number
The height of the ground area from the bottom of the canvas—characters stand on this level
const GROUND_LEVEL = 50;
spiderman
object
Stores all Spider-Man's properties (position, health, velocities) and methods (move, jump, attack, display, swing)
let spiderman = { x: 100, y: 0, health: 100, ... };
deadpool
object
Stores all Deadpool's properties (position, health, velocity) and methods (move, attack, display)
let deadpool = { x: 0, y: 0, health: 120, ... };