Spaces:
Running
Running
Update index.html
Browse files- index.html +12 -5
index.html
CHANGED
|
@@ -52,7 +52,7 @@
|
|
| 52 |
for (let col = 0; col < cols; col++) {
|
| 53 |
let x = col * offsetX + 150;
|
| 54 |
let y = row * hexHeight + (col % 2 ? offsetY : 0) + 50;
|
| 55 |
-
hexGrid.push({ x, y, type: "empty", lifeStage: 0, score: 0,
|
| 56 |
}
|
| 57 |
}
|
| 58 |
}
|
|
@@ -62,7 +62,7 @@
|
|
| 62 |
}
|
| 63 |
|
| 64 |
function drawHex(hex) {
|
| 65 |
-
const { x, y, type,
|
| 66 |
ctx.beginPath();
|
| 67 |
for (let i = 0; i < 6; i++) {
|
| 68 |
let angle = (Math.PI / 3) * i;
|
|
@@ -76,7 +76,11 @@
|
|
| 76 |
ctx.stroke();
|
| 77 |
ctx.fillStyle = "white";
|
| 78 |
ctx.font = "20px Arial";
|
| 79 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 80 |
}
|
| 81 |
|
| 82 |
function getTerrainColor(type) {
|
|
@@ -89,6 +93,9 @@
|
|
| 89 |
hex.lifeStage++;
|
| 90 |
hex.score += hex.lifeStage * 5;
|
| 91 |
totalScore += hex.lifeStage * 5;
|
|
|
|
|
|
|
|
|
|
| 92 |
document.getElementById("scoreboard").innerText = `Total Score: ${totalScore}`;
|
| 93 |
}
|
| 94 |
});
|
|
@@ -102,7 +109,7 @@
|
|
| 102 |
function updateTimer() {
|
| 103 |
timer--;
|
| 104 |
document.getElementById("timer").innerText = `Time Left: ${Math.floor(timer / 60)}:${(timer % 60).toString().padStart(2, '0')}`;
|
| 105 |
-
if (timer %
|
| 106 |
evolveGrid();
|
| 107 |
}
|
| 108 |
renderMap();
|
|
@@ -122,7 +129,7 @@
|
|
| 122 |
if (selectedPlant && resources[selectedPlant] > 0 && hex.type === "empty") {
|
| 123 |
hex.type = "seed";
|
| 124 |
hex.lifeStage = 1;
|
| 125 |
-
hex.
|
| 126 |
resources[selectedPlant]--;
|
| 127 |
document.getElementById("resources").innerText = `Seeds: πΏ${resources["πΏ"]} π${resources["π"]} πΊ${resources["πΊ"]} πΎ${resources["πΎ"]} π${resources["π"]}`;
|
| 128 |
}
|
|
|
|
| 52 |
for (let col = 0; col < cols; col++) {
|
| 53 |
let x = col * offsetX + 150;
|
| 54 |
let y = row * hexHeight + (col % 2 ? offsetY : 0) + 50;
|
| 55 |
+
hexGrid.push({ x, y, type: "empty", lifeStage: 0, score: 0, emojis: [] });
|
| 56 |
}
|
| 57 |
}
|
| 58 |
}
|
|
|
|
| 62 |
}
|
| 63 |
|
| 64 |
function drawHex(hex) {
|
| 65 |
+
const { x, y, type, emojis } = hex;
|
| 66 |
ctx.beginPath();
|
| 67 |
for (let i = 0; i < 6; i++) {
|
| 68 |
let angle = (Math.PI / 3) * i;
|
|
|
|
| 76 |
ctx.stroke();
|
| 77 |
ctx.fillStyle = "white";
|
| 78 |
ctx.font = "20px Arial";
|
| 79 |
+
emojis.forEach((emoji, index) => {
|
| 80 |
+
let randX = x - 10 + (Math.random() * 20 - 10);
|
| 81 |
+
let randY = y + 5 + (Math.random() * 20 - 10);
|
| 82 |
+
ctx.fillText(emoji, randX, randY);
|
| 83 |
+
});
|
| 84 |
}
|
| 85 |
|
| 86 |
function getTerrainColor(type) {
|
|
|
|
| 93 |
hex.lifeStage++;
|
| 94 |
hex.score += hex.lifeStage * 5;
|
| 95 |
totalScore += hex.lifeStage * 5;
|
| 96 |
+
if (hex.lifeStage % 3 === 0) {
|
| 97 |
+
hex.emojis.push(hex.emojis[0]);
|
| 98 |
+
}
|
| 99 |
document.getElementById("scoreboard").innerText = `Total Score: ${totalScore}`;
|
| 100 |
}
|
| 101 |
});
|
|
|
|
| 109 |
function updateTimer() {
|
| 110 |
timer--;
|
| 111 |
document.getElementById("timer").innerText = `Time Left: ${Math.floor(timer / 60)}:${(timer % 60).toString().padStart(2, '0')}`;
|
| 112 |
+
if (timer % 10 === 0) {
|
| 113 |
evolveGrid();
|
| 114 |
}
|
| 115 |
renderMap();
|
|
|
|
| 129 |
if (selectedPlant && resources[selectedPlant] > 0 && hex.type === "empty") {
|
| 130 |
hex.type = "seed";
|
| 131 |
hex.lifeStage = 1;
|
| 132 |
+
hex.emojis.push(selectedPlant);
|
| 133 |
resources[selectedPlant]--;
|
| 134 |
document.getElementById("resources").innerText = `Seeds: πΏ${resources["πΏ"]} π${resources["π"]} πΊ${resources["πΊ"]} πΎ${resources["πΎ"]} π${resources["π"]}`;
|
| 135 |
}
|