Strings
Data Types · Character names, sprite paths, game states.
Strings
What it is
Strings are sequences of characters wrapped in single quotes ('...'), double quotes ("..."), or backticks (`...` for template literals). They support concatenation with +, interpolation inside template literals, and a rich set of methods like .split(), .replace(), .toUpperCase().
Why it matters
Strings label every named thing in the game — file paths to assets, dialogue text shown to the player, state machine values, NPC names. Without strings, you couldn’t load a sprite or display a single line of dialogue.
How GateGame implements it
Sprite paths like 'assets/sprites/octopus.png' tell the loader which image to fetch. Dialogue strings carry the actual words the player reads: "You followed the path all the way here. Are you ready to move on?". Spline IDs like 'seg1' and 'seg2' identify each segment of the maze path. Color values like '#8B4513' are strings the canvas API parses.
Code Example
// String IDs, paths, dialogue, color hex
const id = 'seg1';
const color = '#8B4513';
const path = 'assets/sprites/octopus.png';
const greet = "You followed the path all the way here.";
Key Takeaway
Strings name and describe everything the game knows about. Template literals (backticks) make dynamic strings clean:
`${name}: ${score}`.