about summary refs log tree commit diff stats
path: root/js
diff options
context:
space:
mode:
Diffstat (limited to 'js')
-rw-r--r--js/game-frame/game.js39
1 files changed, 34 insertions, 5 deletions
diff --git a/js/game-frame/game.js b/js/game-frame/game.js
index 744991d..cc463fe 100644
--- a/js/game-frame/game.js
+++ b/js/game-frame/game.js
@@ -134,6 +134,13 @@ const appendRandomItems = () => {
   items.push(...randomItems);
 };
 
+function checkForSpecialItems() {
+  if (player.inventory.find(item => item.type === 'bike')) {
+    player.step = 12;
+  } else {
+    player.step = 8;
+  }
+}
 
 
 
@@ -224,11 +231,8 @@ function gameLoop() {
     }
     return true;
   });
-  if (player.inventory.find(item => item.type === 'bike')) {
-    player.step = 12;
-  } else {
-    player.step = 8;
-  }
+
+  checkForSpecialItems();
 
 
   // Draw signs and check for collisions
@@ -344,6 +348,30 @@ window.addEventListener('keydown', (e) => {
       case 'p':
         player.color = 'blue';
         break;
+    // Add this code where you handle the 'i' key press
+    case 'i':
+      // Create a menu element
+      const menu = document.createElement('div');
+      menu.style.position = 'fixed';
+      menu.style.left = '10px';
+      menu.style.top = '10px';
+      menu.style.backgroundColor = 'white';
+      menu.style.padding = '10px';
+      document.body.appendChild(menu);
+
+      // Add each inventory item to the menu
+      player.inventory.forEach((item) => {
+        const itemElement = document.createElement('div');
+        itemElement.textContent = item.type;
+        itemElement.style.cursor = 'pointer';
+        itemElement.addEventListener('click', () => {
+          player.dropItem(item);
+          items.push(item);
+          menu.remove(); // Remove the entire menu
+        });
+        menu.appendChild(itemElement);
+      });
+      break;
     }
   
     // Calculate the tile coordinates
@@ -356,3 +384,4 @@ window.addEventListener('keydown', (e) => {
       player.y = newY;
     }
 });
+