Spaces:
Sleeping
Sleeping
Update static/game.js
Browse files- static/game.js +14 -9
static/game.js
CHANGED
@@ -5,25 +5,30 @@ class GameStage {
|
|
5 |
this.resources = { food: 0 };
|
6 |
this.population = 1;
|
7 |
this.maxPopulation = 5;
|
|
|
8 |
}
|
9 |
|
10 |
updateUI() {
|
11 |
document.getElementById("resources").textContent = `Food: ${this.resources.food}`;
|
12 |
document.getElementById("population").textContent = `Tribe: ${this.population}/${this.maxPopulation}`;
|
|
|
13 |
}
|
14 |
|
15 |
-
loadAsset(
|
16 |
const img = new Image();
|
17 |
-
img.
|
|
|
18 |
return img;
|
19 |
}
|
20 |
}
|
21 |
|
22 |
-
// Global
|
23 |
-
function gatherFood() {
|
24 |
-
|
|
|
|
|
|
|
|
|
|
|
25 |
}
|
26 |
-
|
27 |
-
function buildHut() {
|
28 |
-
game.buildHut();
|
29 |
-
}
|
|
|
5 |
this.resources = { food: 0 };
|
6 |
this.population = 1;
|
7 |
this.maxPopulation = 5;
|
8 |
+
this.relations = "Neutral"; // Tribal relations
|
9 |
}
|
10 |
|
11 |
updateUI() {
|
12 |
document.getElementById("resources").textContent = `Food: ${this.resources.food}`;
|
13 |
document.getElementById("population").textContent = `Tribe: ${this.population}/${this.maxPopulation}`;
|
14 |
+
document.getElementById("relations").textContent = `Relations: ${this.relations}`;
|
15 |
}
|
16 |
|
17 |
+
loadAsset(url) {
|
18 |
const img = new Image();
|
19 |
+
img.crossOrigin = "Anonymous"; // For CORS compatibility
|
20 |
+
img.src = url;
|
21 |
return img;
|
22 |
}
|
23 |
}
|
24 |
|
25 |
+
// Global UI functions
|
26 |
+
function gatherFood() { game.gatherFood(); }
|
27 |
+
function buildHut() { game.buildHut(); }
|
28 |
+
function attackTribe() { game.attackTribe(); }
|
29 |
+
function socializeTribe() { game.socializeTribe(); }
|
30 |
+
function toggleEditor() {
|
31 |
+
const editor = document.getElementById("editor");
|
32 |
+
editor.style.display = editor.style.display === "none" ? "block" : "none";
|
33 |
}
|
34 |
+
function applyChanges() { game.applyCreatureChanges(); }
|
|
|
|
|
|