bodyWidth
number
Controls the horizontal width of the robot's torso in pixels
let bodyWidth = 100;
bodyHeight
number
Controls the vertical height of the robot's torso in pixels
let bodyHeight = 150;
headRadius
number
Controls the size of the robot's circular head (radius, so diameter is twice this)
let headRadius = 40;
armWidth
number
Controls the thickness of each arm in pixels
let armWidth = 20;
armHeight
number
Controls the length of each arm in pixels
let armHeight = 80;
legWidth
number
Controls the thickness of each leg in pixels
let legWidth = 30;
legHeight
number
Controls the length of each leg in pixels
let legHeight = 100;
robotX
number
Stores the horizontal position of the robot's center on the canvas
let robotX; // Set in setup()
robotY
number
Stores the vertical position of the robot's base center—bounce offsets are added to this in draw()
let robotY; // Set in setup()
headYOffset
number
Negative offset that positions the head above the body center
let headYOffset = -(bodyHeight / 2 + headRadius);
leftArmXOffset
number
Negative offset that positions the left arm to the left of the robot's center
let leftArmXOffset = -(bodyWidth / 2 + armWidth / 2);
rightArmXOffset
number
Positive offset that positions the right arm to the right of the robot's center
let rightArmXOffset = bodyWidth / 2 + armWidth / 2;
armsYOffset
number
Offset that positions both arms vertically—approximately at the shoulder height
let armsYOffset = -(bodyHeight / 2 - armHeight / 4);
legsYOffset
number
Offset that positions the legs below the body center
let legsYOffset = bodyHeight / 2;
eyeRadius
number
Radius of each eye circle on the head
let eyeRadius = 6;
eyeOffsetX
number
Horizontal distance of each eye from the head's center (left is negative, right is positive)
let eyeOffsetX = 15;
eyeOffsetY
number
Vertical offset of the eyes from the head's center (negative moves them up)
let eyeOffsetY = -5;
noseWidth
number
Horizontal width of the nose rectangle
let noseWidth = 10;
noseHeight
number
Vertical height of the nose rectangle
let noseHeight = 15;
noseYOffset
number
Vertical offset of the nose from the head's center (positive moves it down)
let noseYOffset = 10;
headAngle
number
Current rotation angle of the head in radians—incremented each frame while rotating
let headAngle = 0;
leftArmAngle
number
Current swing angle of the left arm in radians—oscillates while animating
let leftArmAngle = 0;
rightArmAngle
number
Current swing angle of the right arm in radians—oscillates while animating
let rightArmAngle = 0;
isHeadRotating
boolean
Flag that controls whether the head is currently spinning—set by clicking the head
let isHeadRotating = false;
initialHeadAngle
number
Stores the head's angle when rotation starts—used to detect when 360 degrees are complete
let initialHeadAngle = 0;
headRotationSpeed
number
How many radians to add to headAngle each frame—controls rotation speed
let headRotationSpeed = 0.1;
isLeftArmAnimating
boolean
Flag that controls whether the left arm is waving—toggled by clicking it
let isLeftArmAnimating = false;
isRightArmAnimating
boolean
Flag that controls whether the right arm is waving—toggled by clicking it
let isRightArmAnimating = false;
leftArmPhase
number
Phase value for the left arm's sine wave animation—determines position in the wave cycle
let leftArmPhase = 0;
rightArmPhase
number
Phase value for the right arm's sine wave animation—determines position in the wave cycle
let rightArmPhase = 0;
armAnimationAmplitude
number
Maximum swing angle for arms in radians—controls how far they swing side to side
let armAnimationAmplitude; // Set in setup() to PI / 4
armAnimationSpeed
number
How many radians to add to the arm phase each frame—controls waving speed
let armAnimationSpeed = 0.05;
isBouncing
boolean
Flag that controls whether the entire robot is bouncing—toggled by clicking the body
let isBouncing = false;
bouncePhase
number
Phase value for the bounce's sine wave—determines position in the up-down cycle
let bouncePhase = 0;
bounceAmplitude
number
How many pixels the robot bounces up and down—controls bounce height
let bounceAmplitude = 20;
bounceSpeed
number
How many radians to add to bouncePhase each frame—controls bounce speed
let bounceSpeed = 0.1;