🧮 Data Types

Objects (JSON)

Project Evidence Required
Configuration objects and sprite data.
Assessment Method
Code review: Object literals

What it is

Objects are unordered collections of key-value pairs created with {}. They’re JavaScript’s most flexible data structure — properties can be added, removed, or reassigned at runtime. Object literals look like JSON and are the natural way to express configuration.

Why it matters

Object literals are how you turn game design into data. Every sprite, every NPC, every barrier is described by an object with a few well-known fields. The engine reads these objects and acts on them. Change the data, change the game.

How GateGame implements it

Every entity in the level is configured by an object literal. The spline() helper returns one. Sprite data like sprite_data_octopus is an object. The this.classes entries each pair a class reference with a data object. Dialogue buttons are objects with text, primary, and action fields.

Code Example

// Object literal returned from spline()
return {
  id,
  splinePoints: [...],
  visible: true,
  color: '#8B4513',
  lineWidth: 22,
};

// Object literal for a dialogue button
{ text: "Step Through", primary: true, action: () => { /*...*/ } }

Key Takeaway

Object literals are the syntax of configuration. If a piece of your game has more than two adjustable knobs, it’s probably an object.