varscoreboard =newScoreboard();
scoreboard.timer();
scoreboard.countdown(40);
scoreboard.help(
"Get the green ring. "+
"Click and drag blue ramps. "+
"Click blue ramps and press S to spin. "+
"Left and right arrows to move player. "+
"Be quick!"
);
scoreboard.onTimeExpired(function() {
scoreboard.setMessage("Game Over!");
gameOver();
});varpause = false;
functiongameOver() {
if(scoreboard.getTimeRemaining() > 0) scoreboard.setMessage('Win!');
scoreboard.stopCountdown();
scoreboard.stopTimer();
pause = true;
}functionLevels(scoreboard, scene) {
this.scoreboard = scoreboard;
this.scene = scene;
this.levels = [];
this.current_level = 0;
}Levels.prototype.addLevel =function(things_on_this_level) {
this.levels.push(things_on_this_level);
};Levels.prototype.thingsOnCurrentLevel =function() {
returnthis.levels[this.current_level];
};Levels.prototype.draw =function() {
varscene = this.scene;
this.thingsOnCurrentLevel().forEach(function(thing) {
scene.add(thing);
});
};Levels.prototype.erase =function() {
varscene = this.scene;
this.thingsOnCurrentLevel().forEach(function(obstacle) {
scene.remove(obstacle);
});report erratum • discussCode: Multilevel Game • 263
Prepared exclusively for Michael Powell