about summary refs log tree commit diff stats
path: root/js
diff options
context:
space:
mode:
authorelioat <elioat@tilde.institute>2023-12-29 17:44:06 -0500
committerelioat <elioat@tilde.institute>2023-12-29 17:44:06 -0500
commitfa55b19c10dcd4b8b6cfe97f3c33ff51a08d50bc (patch)
tree3e0ac67902dbcf302feaf8436577b4696cea9f1b /js
parent904bae47d39a762a517ef8daf08f49822b52094e (diff)
downloadtour-fa55b19c10dcd4b8b6cfe97f3c33ff51a08d50bc.tar.gz
*
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;
     }
 });
+