about summary refs log tree commit diff stats
path: root/js/game-frame/game.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/game-frame/game.js')
-rw-r--r--js/game-frame/game.js88
1 files changed, 49 insertions, 39 deletions
diff --git a/js/game-frame/game.js b/js/game-frame/game.js
index fabc6bf..9a1b7fb 100644
--- a/js/game-frame/game.js
+++ b/js/game-frame/game.js
@@ -70,21 +70,22 @@ let items = [
 ];
 
 
-// Pushable items
-// Define the PushableItem class
-function PushableItem(x, y, width, height, color) {
-  this.x = x;
-  this.y = y;
-  this.width = width;
-  this.height = height;
-  this.color = color;
-}
+// // Pushable items
+// // Define the PushableItem class
+// function PushableItem(x, y, width, height, color) {
+//   this.x = x;
+//   this.y = y;
+//   this.width = width;
+//   this.height = height;
+//   this.color = color;
+// }
 
-// Create some pushable items
-let pushableItems = [
-  new PushableItem(24, 48, player.width, player.height, 'green'),
-  new PushableItem(48, 24, player.width, player.height, 'green'),
-];
+// // Create some pushable items
+// let pushableItems = [
+//   new PushableItem(24, 48, player.width, player.height, 'green'),
+//   new PushableItem(48, 24, player.width, player.height, 'green'),
+//   new PushableItem(48, 248, player.width, player.height, 'green'),
+// ];
 
 
 
@@ -155,32 +156,41 @@ function gameLoop() {
 
 
 
-    // Draw pushable items
-    pushableItems.forEach(item => {
-      ctx.fillStyle = item.color;
-      ctx.fillRect(item.x, item.y, item.width, item.height);
-    });
+    // // Draw pushable items
+    // pushableItems.forEach(item => {
+    //   ctx.fillStyle = item.color;
+    //   ctx.fillRect(item.x, item.y, item.width, item.height);
+    // });    
+    
+    // // Determine if the player is about to push a pushable item
+    // let pushableItem = null;
+    // for (let i = 0; i < pushableItems.length; i++) {
+    //   if (player.x + player.width === pushableItems[i].x && player.y === pushableItems[i].y) {
+    //     pushableItem = pushableItems[i];
+    //   }
+    // }
+
+    // // If there is a pushable item, check if the player can push it
+    // if (pushableItem) {
+    //   // Calculate the next pixel coordinates
+    //   const nextX = pushableItem.x + player.step;
+    //   const nextY = pushableItem.y + player.step;
+
+    //   // Calculate the tile coordinates
+    //   const tileX = Math.floor(nextX / TILE_SIZE);
+    //   const tileY = Math.floor(nextY / TILE_SIZE);
+
+    //   // Check if the next pixel is within the map boundaries
+    //   if (nextX >= 0 && nextX < canvas.width && nextY >= 0 && nextY < canvas.height) {
+    //     // Check if the next pixel is walkable
+    //     if (map[tileY] && map[tileY][tileX] && map[tileY][tileX].walkable) {
+    //       // Update the pushable item's position
+    //       pushableItem.x = nextX;
+    //     }
+    //   }
+    // }
 
-    // Handle pushable items
-    // FIXME: this doesn't work correctly
-    for (let i = 0; i < pushableItems.length; i++) {
-      if (player.x === pushableItems[i].x && player.y === pushableItems[i].y) {
-        // Calculate the tile coordinates
-        const tileX = Math.floor(pushableItems[i].x / TILE_SIZE);
-        const tileY = Math.floor(pushableItems[i].y / TILE_SIZE);
-
-        // Calculate the new position
-        let newX = pushableItems[i].x + player.step;
-        let newY = pushableItems[i].y + player.step;
-
-        // Check if the new tile is walkable
-        if (map[tileY] && map[tileY][tileX] && map[tileY][tileX].walkable) {
-          // Update the item's position
-          pushableItems[i].x = newX;
-          pushableItems[i].y = newY;
-        }
-      }
-    }
+  
     
     
 
b39e'>34a60763 ^
f07bb12f ^

34a60763 ^
f07bb12f ^

34a60763 ^
f07bb12f ^
34a60763 ^
f07bb12f ^





34a60763 ^
f07bb12f ^





34a60763 ^
f07bb12f ^

34a60763 ^
f07bb12f ^

34a60763 ^
f07bb12f ^



34a60763 ^
f07bb12f ^
34a60763 ^
f07bb12f ^
34a60763 ^
f07bb12f ^






f07bb12f ^

34a60763 ^
f07bb12f ^
34a60763 ^





f07bb12f ^
34a60763 ^

f07bb12f ^
34a60763 ^
f07bb12f ^
34a60763 ^





f07bb12f ^
34a60763 ^

f07bb12f ^
34a60763 ^





f07bb12f ^




34a60763 ^

f07bb12f ^
34a60763 ^

f07bb12f ^










34a60763 ^
f07bb12f ^


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204