broadfield-dev commited on
Commit
ad41998
·
verified ·
1 Parent(s): b5e7d4b

Create game.js

Browse files
Files changed (1) hide show
  1. static/game.js +29 -0
static/game.js ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ class GameStage {
2
+ constructor(canvas) {
3
+ this.canvas = canvas;
4
+ this.ctx = canvas.getContext("2d");
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(path) {
16
+ const img = new Image();
17
+ img.src = path;
18
+ return img;
19
+ }
20
+ }
21
+
22
+ // Global functions for UI buttons
23
+ function gatherFood() {
24
+ game.gatherFood();
25
+ }
26
+
27
+ function buildHut() {
28
+ game.buildHut();
29
+ }