67 lines
1.8 KiB
JavaScript
67 lines
1.8 KiB
JavaScript
const asdf = require("asdf-games");
|
|
// eslint-disable-next-line no-unused-vars
|
|
const { Text, Container, Rect, Texture, Sprite } = asdf;
|
|
|
|
const text = require(__dirname + "/../../res/lang/default.js");
|
|
const fillStyleHeadline = {fill: "#ffffff", font: "24px Minecraft"};
|
|
const fillStyleNormal = {fill: "#ffffff", font: "16px Minecraft"};
|
|
|
|
const logo = new Texture(__dirname + "/../../res/images/logo.png");
|
|
|
|
class Credits extends Container {
|
|
constructor(game, keys, onEnd) {
|
|
super();
|
|
this.game = game;
|
|
this.keys = keys;
|
|
this.onEnd = onEnd;
|
|
|
|
this.children = [];
|
|
|
|
this.debounceTime = 2;
|
|
|
|
this.add(new Rect(this.game.w, this.game.h, { fill: "#333333" }));
|
|
|
|
const logoSprite = new Sprite(logo);
|
|
logoSprite.pos = { x: 160, y: 0 };
|
|
logoSprite.scale = { x: 0.5, y: 0.5 };
|
|
this.add(logoSprite);
|
|
|
|
const creditsText = new Text(text.credits.credits, fillStyleHeadline);
|
|
creditsText.pos = { x: 260, y: 120 };
|
|
this.add(creditsText);
|
|
|
|
const arneText = new Text(text.credits.arne, fillStyleNormal);
|
|
arneText.pos = { x: 125, y: 170 };
|
|
this.add(arneText);
|
|
|
|
const jobText = new Text(text.credits.job, fillStyleNormal);
|
|
jobText.pos = { x: 125, y: 200 };
|
|
this.add(jobText);
|
|
|
|
const hannahText = new Text(text.credits.hannah, fillStyleNormal);
|
|
hannahText.pos = { x: 125, y: 230 };
|
|
this.add(hannahText);
|
|
|
|
const logoText = new Text(text.credits.font, fillStyleNormal);
|
|
logoText.pos = { x: 125, y: 260 };
|
|
this.add(logoText);
|
|
|
|
var instruction = new Text(text.gameOver.instruction, fillStyleNormal);
|
|
instruction.pos = { x: 175, y: 300 };
|
|
this.add(instruction);
|
|
|
|
}
|
|
|
|
update(dt, t) {
|
|
super.update(dt, t);
|
|
|
|
if (this.keys.action && this.debounceTime <= 0) {
|
|
this.onEnd();
|
|
}
|
|
|
|
this.debounceTime -= dt;
|
|
|
|
}
|
|
}
|
|
|
|
module.exports = Credits; |