Code Studio · Level 9
Mini Game Engine 🕹️
Time to be a game engine. Combine a class, an array, and a loop to run a tiny game — your player collects loot and the screen updates, exactly like every real game.
Run a tiny game.
Example code
class Player {
constructor(name) {
this.name = name;
this.items = [];
}
collect(item) {
this.items.push(item);
say(this.name + " collected " + item);
}
}
let player = new Player("Bolt");
player.collect("star");
player.collect("key");
🧩 Tap to add code blocks — build a player, then collect loot
Name your player Bolt, Nova, Dragon, Unicorn, Cat, Dog… for an avatar.
star
key
rocket
…any other loot becomes a 📦 crate!
star
key
rocket
…any other loot becomes a 📦 crate!
Your game, running live
PLAYER
—
★ 0
Run your code to start the game…
INVENTORY (player.items)
Waiting for your game…
🕹️ Game engine running! Level complete.
You ran a real game loop: a class made the player, an array (this.items) held the loot, and a method updated the screen every time it ran.