Skip to content

Commit

Permalink
Added tile colors
Browse files Browse the repository at this point in the history
  • Loading branch information
creeperkafasi committed Jul 13, 2023
1 parent 4e431a3 commit 71547b2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 24 deletions.
38 changes: 15 additions & 23 deletions game.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,14 +131,17 @@ setInterval(() => {
// Initialize empty tiles with "e" so to not be confused with out of bounds tiles
if (!Table[`${x},${y}`]) Table[`${x},${y}`] = "e";

let tileColor = mod(y + 1, 3);
// Draw tile
ctx.strokeStyle = "black";
ctx.fillStyle = tileColor == 0 ? "#d18b47" : tileColor == 1 ? "#e8ab6f" : "#ffce9e";
ctx.beginPath();
ctx.ellipse(
start[0] + x * R3 * r,
start[1] + y * r,
r, r, 0, 0, 360);
ctx.stroke();
// ctx.stroke();
ctx.fill();
ctx.closePath();


Expand Down Expand Up @@ -168,17 +171,6 @@ setInterval(() => {
[[x + 1, y - 1], [x - 1, y - 1]]
).filter((c) => !checkAvailable(...c) && !checkSameColor(c[0], c[1], x, y))
);

moves.forEach((move) => {
ctx.fillStyle = "#55ff5544"
ctx.beginPath();
ctx.ellipse(
start[0] + (move[0]) * R3 * r,
start[1] + (move[1]) * r,
r, r, 0, 0, 360);
ctx.fill();
ctx.closePath();
});
break;
case 'b':
moves = Moves.diagonal.map(
Expand Down Expand Up @@ -226,17 +218,6 @@ setInterval(() => {
default:
break;
}

moves.forEach((move) => {
ctx.fillStyle = "#55ff5544"
ctx.beginPath();
ctx.ellipse(
start[0] + (move[0]) * R3 * r,
start[1] + (move[1]) * r,
r, r, 0, 0, 360);
ctx.fill();
ctx.closePath();
});
}
}

Expand All @@ -249,6 +230,17 @@ setInterval(() => {
);
}

moves.forEach((move) => {
ctx.fillStyle = "#55ff5511"
ctx.beginPath();
ctx.ellipse(
start[0] + (move[0]) * R3 * r,
start[1] + (move[1]) * r,
r / 3, r / 3, 0, 0, 360);
ctx.fill();
ctx.closePath();
});

// Draw debug info
// ctx.beginPath();
// ctx.strokeStyle = "blue";
Expand Down
1 change: 0 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ <h1>Hexagonal Chess Board</h1>
<h4>---Currently missing features & excuses---</h4>
- Win/Lose system: Check yourself <br>
- Check and mate detection: Check yourself <br>
- Colors: Too lazy <br>
- "En Passant": Idk how to <br>
- Turn system: Check yourself <br>
- AI: Idk how to <br>
Expand Down

0 comments on commit 71547b2

Please sign in to comment.