Eliminated graphic bug that tiny gaps appear between blocks + added new theme "Clean"
This commit is contained in:
@@ -27,6 +27,10 @@
|
|||||||
<input id="theme-default" name="theme" data-theme="default" type="radio" checked>
|
<input id="theme-default" name="theme" data-theme="default" type="radio" checked>
|
||||||
<label for="theme-default" class="radio-label" data-string="themeDefault">Default</label>
|
<label for="theme-default" class="radio-label" data-string="themeDefault">Default</label>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="radio">
|
||||||
|
<input type="radio" id="theme-clean" name="theme" data-theme="clean">
|
||||||
|
<label for="theme-clean" class="radio-label" data-string="themeClean">Clean</label>
|
||||||
|
</div>
|
||||||
<div class="radio">
|
<div class="radio">
|
||||||
<input id="theme-modern" name="theme" data-theme="modern" type="radio">
|
<input id="theme-modern" name="theme" data-theme="modern" type="radio">
|
||||||
<label for="theme-modern" class="radio-label" data-string="themeModern">Modern</label>
|
<label for="theme-modern" class="radio-label" data-string="themeModern">Modern</label>
|
||||||
|
17
js/game.js
17
js/game.js
@@ -38,17 +38,20 @@ class Game {
|
|||||||
}
|
}
|
||||||
|
|
||||||
drawTile(x, y, offset, color, matrix, ctx = this.g.context) {
|
drawTile(x, y, offset, color, matrix, ctx = this.g.context) {
|
||||||
|
ctx.fillStyle = color;
|
||||||
|
x += offset.x;
|
||||||
|
y += offset.y;
|
||||||
switch (this.g.theme) {
|
switch (this.g.theme) {
|
||||||
case "default":
|
case "default":
|
||||||
ctx.fillStyle = color;
|
ctx.fillRect(x + tileGap / 2, y + tileGap / 2, 1 - tileGap, 1 - tileGap);
|
||||||
ctx.fillRect(x + offset.x + tileGap / 2, y + offset.y + tileGap / 2, 1 - tileGap, 1 - tileGap);
|
break;
|
||||||
|
case "clean":
|
||||||
|
ctx.fillRect(x, y, 1, 1);
|
||||||
break;
|
break;
|
||||||
case "modern":
|
case "modern":
|
||||||
ctx.fillStyle = color;
|
drawRoundRect(ctx, x + tileGap / 2, y + tileGap / 2, 1 - tileGap, 1 - tileGap, .15);
|
||||||
drawRoundRect(ctx, x + offset.x + tileGap / 2, y + offset.y + tileGap / 2, 1 - tileGap, 1 - tileGap, .15);
|
|
||||||
break;
|
break;
|
||||||
case "snakes":
|
case "snakes":
|
||||||
ctx.fillStyle = color;
|
|
||||||
let r1 = .15, // top right
|
let r1 = .15, // top right
|
||||||
r2 = .15, // bottom right
|
r2 = .15, // bottom right
|
||||||
r3 = .15, // bottom left
|
r3 = .15, // bottom left
|
||||||
@@ -73,10 +76,10 @@ class Game {
|
|||||||
r2 = 0;
|
r2 = 0;
|
||||||
r3 = 0;
|
r3 = 0;
|
||||||
}
|
}
|
||||||
drawRoundRect(ctx, x + offset.x, y + offset.y, 1, 1, [r1, r2, r3, r4]);
|
drawRoundRect(ctx, x, y, 1, 1, [r1, r2, r3, r4]);
|
||||||
break;
|
break;
|
||||||
case "retro":
|
case "retro":
|
||||||
drawReliefRect(ctx, x + offset.x, y + offset.y, 1, 1, .15, color);
|
drawReliefRect(ctx, x, y, 1, 1, .15, color);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
this.g.theme = "default";
|
this.g.theme = "default";
|
||||||
|
@@ -12,6 +12,7 @@ const en = {
|
|||||||
counterScore: "Score: ",
|
counterScore: "Score: ",
|
||||||
counterTime: "Time: ",
|
counterTime: "Time: ",
|
||||||
themeDefault: "Default",
|
themeDefault: "Default",
|
||||||
|
themeClean: "Clean",
|
||||||
themeModern: "Modern",
|
themeModern: "Modern",
|
||||||
themeRetro: "Retro",
|
themeRetro: "Retro",
|
||||||
themeSnakes: "Snakes",
|
themeSnakes: "Snakes",
|
||||||
@@ -36,6 +37,7 @@ const de = {
|
|||||||
counterScore: "Punkte: ",
|
counterScore: "Punkte: ",
|
||||||
counterTime: "Zeit: ",
|
counterTime: "Zeit: ",
|
||||||
themeDefault: "Standard",
|
themeDefault: "Standard",
|
||||||
|
themeClean: "Glattpoliert",
|
||||||
themeModern: "Modern",
|
themeModern: "Modern",
|
||||||
themeRetro: "Retro",
|
themeRetro: "Retro",
|
||||||
themeSnakes: "Schlangen",
|
themeSnakes: "Schlangen",
|
||||||
|
18
js/menu.js
18
js/menu.js
@@ -23,26 +23,32 @@ function scaleWindow() {
|
|||||||
height = width * (5 / 3);
|
height = width * (5 / 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
width = Math.floor(width);
|
||||||
|
height = Math.floor(height);
|
||||||
|
|
||||||
canvasContainer.style.height = height + "px";
|
canvasContainer.style.height = height + "px";
|
||||||
canvasContainer.style.width = conWidth + "px";
|
canvasContainer.style.width = conWidth + "px";
|
||||||
|
|
||||||
|
const canvasScale = width / game.g.fieldSize.x;
|
||||||
|
|
||||||
game.g.canvasBg.height = height;
|
game.g.canvasBg.height = height;
|
||||||
game.g.canvasBg.width = width;
|
game.g.canvasBg.width = width;
|
||||||
game.g.contextBg.scale(width / game.g.fieldSize.x, height / game.g.fieldSize.y);
|
game.g.contextBg.scale(canvasScale, canvasScale);
|
||||||
|
|
||||||
game.g.canvas.height = height;
|
game.g.canvas.height = height;
|
||||||
game.g.canvas.width = width;
|
game.g.canvas.width = width;
|
||||||
game.g.context.scale(width / game.g.fieldSize.x, height / game.g.fieldSize.y);
|
game.g.context.scale(canvasScale, canvasScale);
|
||||||
|
|
||||||
game.g.canvasHold.height = height / game.g.fieldSize.y * 5;
|
game.g.canvasHold.height = game.g.canvasHold.width = height / game.g.fieldSize.y * 5;
|
||||||
game.g.canvasHold.width = game.g.canvasHold.height;
|
|
||||||
game.g.canvasHold.style.transform = "translate(-100%, -.2em) translateX(-" + width / 2 + "px)";
|
game.g.canvasHold.style.transform = "translate(-100%, -.2em) translateX(-" + width / 2 + "px)";
|
||||||
game.g.contextHold.scale(game.g.canvasHold.width / 6, game.g.canvasHold.width / 6);
|
const contextHoldScale = Math.floor(game.g.canvasHold.width / 6);
|
||||||
|
game.g.contextHold.scale(contextHoldScale, contextHoldScale);
|
||||||
|
|
||||||
game.g.canvasUpcoming.width = height / game.g.fieldSize.y * 5;
|
game.g.canvasUpcoming.width = height / game.g.fieldSize.y * 5;
|
||||||
game.g.canvasUpcoming.height = game.g.canvasUpcoming.width * 3;
|
game.g.canvasUpcoming.height = game.g.canvasUpcoming.width * 3;
|
||||||
game.g.canvasUpcoming.style.transform = "translate(100%, -.2em) translateX(" + width / 2 + "px)";
|
game.g.canvasUpcoming.style.transform = "translate(100%, -.2em) translateX(" + width / 2 + "px)";
|
||||||
game.g.contextUpcoming.scale(game.g.canvasUpcoming.width / 6, game.g.canvasUpcoming.width / 6);
|
const contextUpcomingScale = Math.floor(game.g.canvasUpcoming.width / 6);
|
||||||
|
game.g.contextUpcoming.scale(contextUpcomingScale, contextUpcomingScale);
|
||||||
|
|
||||||
if (!firstRun && game.g.isPaused) {
|
if (!firstRun && game.g.isPaused) {
|
||||||
game.draw();
|
game.draw();
|
||||||
|
Reference in New Issue
Block a user