Code Studio · Level 9
Mini Game Engine
Time to be a game engine. Combine classes, arrays, and loops to run a tiny simulation — every frame of every game you've played works exactly like this.
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");
Program result
PLAYER 1
SCORE 0
- Run your code to see output.
Type real JavaScript, then run it.
Game engine ran.
You combined a class, an array, and a method to update a player object.
Open Game Builder