🧮 Data Types

Booleans

Project Evidence Required
Flags such as isJumping, isPaused, isVulnerable.
Assessment Method
Code review: Boolean logic

What it is

A boolean is a true or false value. JavaScript also treats many other values as truthy or falsy when used in conditionals — 0, '', null, undefined, and NaN are falsy; everything else is truthy.

Why it matters

Booleans are the on/off switches that drive game state. Is the dialogue open? Is the player paused? Is this barrier visible right now? Each is a boolean, and combining them lets you express any state machine.

How GateGame implements it

SplineBarriers have a visible: true boolean that controls whether they render. The dialogue system tracks isDialogueOpen() to decide whether to pause input. Dialogue buttons mark one option as primary: true to style it differently. The ‘Step Through’ callback inside the Exit Warden uses booleans to gate the level transition.

Code Example

// Boolean flags throughout the level config
return {
  id,
  splinePoints: [...],
  visible: true,                 // ← shows on canvas
  color: '#8B4513',
  lineWidth: 22,
};

// Dialogue button with a boolean style flag
{ text: "Step Through", primary: true, action: () => { /*...*/ } }

Key Takeaway

Booleans turn complex game state into readable English: if (this.isOnGround && !this.isJumping). Use them liberally.