Add new retro theme & fix touch input problem

This commit is contained in:
Marcel
2018-02-18 12:45:54 +01:00
parent a289edaae9
commit d5cd080aba
9 changed files with 122 additions and 35 deletions

View File

@@ -18,6 +18,8 @@ class Game {
}
drawHolding() {
if (this.p.holdingTile === null)
return;
this.g.contextHold.clearRect(0, 0, this.g.canvasHold.width, this.g.canvasHold.height);
const offset = centerOffset(this.p.holdingTile);
const x = 3 - (this.p.holdingTile[0].length / 2) + offset.x;
@@ -35,8 +37,7 @@ class Game {
});
}
drawTile(x, y, offset, color, matrix, useContext = this.g.context) {
const ctx = useContext;
drawTile(x, y, offset, color, matrix, ctx = this.g.context) {
switch (this.g.theme) {
case "default":
ctx.fillStyle = color;
@@ -74,6 +75,9 @@ class Game {
}
drawRoundRect(ctx, x + offset.x, y + offset.y, 1, 1, [r1, r2, r3, r4]);
break;
case "retro":
drawReliefRect(ctx, x + offset.x, y + offset.y, 1, 1, .15, color);
break;
default:
this.g.theme = "default";
this.drawTile(x, y, offset, color, matrix, ctx);
@@ -115,6 +119,13 @@ class Game {
this.drawArena();
}
redrawScreen() {
this.draw();
this.drawArena();
this.drawHolding();
this.drawUpcoming();
}
registerListeners() {
// Keyboard controls
document.addEventListener('keydown', event => {