cosimotaiuti commited on
Commit
42ab4a9
·
verified ·
1 Parent(s): 13ec27a

Upload game.js

Browse files
Files changed (1) hide show
  1. static/game/game.js +44 -41
static/game/game.js CHANGED
@@ -9,7 +9,10 @@ let baseMapImg;
9
  let girlfriendImg;
10
  let clownImg;
11
 
12
- let isSoundOn = localStorage.getItem("isSoundOn") === null ? true : localStorage.getItem("isSoundOn") !== "false";
 
 
 
13
  const soundIcon = document.getElementById("soundIcon");
14
  const bgMusic = document.getElementById("bgMusic");
15
 
@@ -20,51 +23,51 @@ let chatMessages = [];
20
  let furnitureSprites = {};
21
 
22
  function setup() {
23
- baseMapImg = loadImage('/assets/img/appartment/baseMap.PNG');
24
- girlfriendImg = loadImage('/assets/img/gf.png');
25
- clownImg = loadImage('/assets/img/clown.png');
26
 
27
- gameState = new GameState({
28
- ...getApt(),
29
- grid: getGrid(),
30
- furniture:getFurniture()
31
- });
32
 
33
- furnitureSprites = loadFurnitureSprites(gameState.map_data.furniture);
34
 
35
- GRID_COLS = gameState.map_data.gridCols;
36
- GRID_ROWS = gameState.map_data.gridRows;
37
 
38
- girlfriend = new Girlfriend(gameState, girlfriendImg);
39
- clown = new Clown(gameState, clownImg);
40
 
41
- // Once loaded, initialize the P5 canvas with correct dims
42
- let canvas = createCanvas(GRID_COLS * CELL_SIZE, GRID_ROWS * CELL_SIZE);
43
- canvas.parent('mapWrapper');
44
- adjustScale();
45
  }
46
 
47
  function draw() {
48
- clear();
49
-
50
- if (baseMapImg) {
51
- image(baseMapImg, 0, 0, GRID_COLS * CELL_SIZE, GRID_ROWS * CELL_SIZE);
52
- }
53
- if(furnitureSprites) {
54
- drawFurniture(gameState.map_data.furniture, furnitureSprites);
55
- }
56
- drawGrid();
57
- // drawWallsAndDoors();
58
-
59
- drawLabels(gameState.map_data.rooms);
60
-
61
- if (girlfriend) {
62
- girlfriend.drawPath(CELL_SIZE);
63
- girlfriend.draw(CELL_SIZE);
64
- }
65
- if (clown) {
66
- clown.checkForGirlfriend(girlfriend);
67
- clown.drawPath(CELL_SIZE);
68
- clown.draw(CELL_SIZE);
69
- }
70
- }
 
9
  let girlfriendImg;
10
  let clownImg;
11
 
12
+ let isSoundOn =
13
+ localStorage.getItem("isSoundOn") === null
14
+ ? true
15
+ : localStorage.getItem("isSoundOn") !== "false";
16
  const soundIcon = document.getElementById("soundIcon");
17
  const bgMusic = document.getElementById("bgMusic");
18
 
 
23
  let furnitureSprites = {};
24
 
25
  function setup() {
26
+ baseMapImg = loadImage("/assets/img/appartment/BaseMap.PNG");
27
+ girlfriendImg = loadImage("/assets/img/gf.png");
28
+ clownImg = loadImage("/assets/img/clown.png");
29
 
30
+ gameState = new GameState({
31
+ ...getApt(),
32
+ grid: getGrid(),
33
+ furniture: getFurniture(),
34
+ });
35
 
36
+ furnitureSprites = loadFurnitureSprites(gameState.map_data.furniture);
37
 
38
+ GRID_COLS = gameState.map_data.gridCols;
39
+ GRID_ROWS = gameState.map_data.gridRows;
40
 
41
+ girlfriend = new Girlfriend(gameState, girlfriendImg);
42
+ clown = new Clown(gameState, clownImg);
43
 
44
+ // Once loaded, initialize the P5 canvas with correct dims
45
+ let canvas = createCanvas(GRID_COLS * CELL_SIZE, GRID_ROWS * CELL_SIZE);
46
+ canvas.parent("mapWrapper");
47
+ adjustScale();
48
  }
49
 
50
  function draw() {
51
+ clear();
52
+
53
+ if (baseMapImg) {
54
+ image(baseMapImg, 0, 0, GRID_COLS * CELL_SIZE, GRID_ROWS * CELL_SIZE);
55
+ }
56
+ if (furnitureSprites) {
57
+ drawFurniture(gameState.map_data.furniture, furnitureSprites);
58
+ }
59
+ //drawGrid();
60
+ // drawWallsAndDoors();
61
+
62
+ drawLabels(gameState.map_data.rooms);
63
+
64
+ if (girlfriend) {
65
+ girlfriend.drawPath(CELL_SIZE);
66
+ girlfriend.draw(CELL_SIZE);
67
+ }
68
+ if (clown) {
69
+ clown.checkForGirlfriend(girlfriend);
70
+ clown.drawPath(CELL_SIZE);
71
+ clown.draw(CELL_SIZE);
72
+ }
73
+ }