38 lines
951 B
JavaScript
38 lines
951 B
JavaScript
const asdf = require("asdf-games");
|
|
// eslint-disable-next-line no-unused-vars
|
|
const { Text, Container, Rect } = asdf;
|
|
|
|
const text = require(__dirname + "/../../res/lang/default.js");
|
|
const fillStyle = {fill: "#ffffff", font: "24px Minecraft"};
|
|
|
|
class GameOver extends Container {
|
|
constructor(game, keys, onEnd) {
|
|
super();
|
|
this.game = game;
|
|
this.keys = keys;
|
|
this.onEnd = onEnd;
|
|
|
|
this.children = [];
|
|
|
|
this.add(new Rect(this.game.w, this.game.h, { fill: "#333333" }));
|
|
|
|
var gameover = new Text(text.gameOver.dead, {fill: "#bb0a1e", font: "60px Minecraft"});
|
|
gameover.pos = { x: 188, y: 150 };
|
|
this.add(gameover);
|
|
|
|
var instruction = new Text(text.gameOver.instruction, fillStyle);
|
|
instruction.pos = { x: 125, y: 216 };
|
|
this.add(instruction);
|
|
}
|
|
|
|
update(dt, t) {
|
|
super.update(dt, t);
|
|
|
|
if (this.keys.action) {
|
|
this.onEnd();
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
module.exports = GameOver; |