Back to Mini Game Engine
Code Studio · Level 9

Game Builder

Students add game actions that change state and print the player inventory.

20-25 min Ages 9-12 Builder JavaScript
Code Editor

Build a player inventory.

Example code
class Player {
  constructor(name) {
    this.name = name;
    this.score = 0;
    this.inventory = [];
  }

  collect(item, points) {
    this.inventory.push(item);
    this.score = this.score + points;
    say(this.name + " found " + item);
  }

  showStatus() {
    say("Score: " + this.score);
    say("Items: " + this.inventory.join(", "));
  }
}

let explorer = new Player("Nova");
explorer.collect("star", 10);
explorer.collect("badge", 5);
explorer.showStatus();
Output

Program result

PLAYER 1 SCORE 0
Your player character
Robot ready to speak your strings

Type real JavaScript, then run it.