Commits

abrie  committed eec8721

add the note item feature, accessed through a magic dance.

  • Participants
  • Parent commits 8474237

Comments (0)

Files changed (4)

File inventory.js

                     id:4,
                     name:"kicks",
                 }
-           }
+           },
+        5: function() {
+                return {
+                    id:5,
+                    name:"note",
+                }
+           },
     }
 
     var getItem = function(id) {
         return that;
     }
 
+    var createButton = function( name, onPressed ) {
+        var that = {
+            elementPressed: function(e) {
+                onPressed();
+            },
+        }
+
+        that.button = document.createElement("button");
+        that.button.innerHTML = name;
+        that.button.onclick = that.elementPressed;
+        kitElement.appendChild(that.button);
+        return that;
+    }
+
     var toggles = {};
     var addToggle = function( name, initialState, onToggle ) {
         toggles[name] = createToggle( name, initialState, onToggle );
         onToggle(initialState);
     }
 
+    var buttons = {}
+    var addButton = function( name, onclick ) {
+        buttons[name] = createButton(name, onclick);
+    }
+
     return {
         addToggle:addToggle,
+        addButton:addButton
     }
 });
                      description: "kicks",
                      stack: undefined,
                 },
+                5: { eye: {
+                        description:"page",
+                        color:0x89180F,
+                        meshGenerator:itemMeshGenerator
+                     },
+                     description: "page",
+                     stack: undefined,
+                },
             },
         }
     }());
-define(['./map','./input','./kit'], function(map,input,kit) {
+define(['./map','./input','./kit','./inventory'], function(map,input,kit,inventory) {
     var playerObjects = (function(){
         var list = [];
         var add = function(obj) {
     }
 
     var filterStack = ["eye"];
-    var inventory = [];
+    var playerInventory = [];
     var isWearingSpaceSuit = false;
     var isWearingDanceShoes = false;
 
         playerObjects.rerender();
     }
 
+    var noteButtonPressed = function() {
+        console.log("goto this url:http://ddasd.dddsdasdasd.dds");
+    }
+
     var addInventory = function(item) {
-        inventory.push(item);
-        console.log("item added to inventory:",item.name);
+        playerInventory.push(item);
+        console.log("item added to playerInventory:",item.name);
         if( item.name === "shades" ) {
             kit.addToggle("shades", false, redFilterToggled);
             return;
             kit.addToggle("kicks", false, danceShoesToggled);
             return;
         }
+        if( item.name === "note") {
+            kit.addButton("note", noteButtonPressed);
+            return;
+        }
     }
 
     var that = {
                 case "LEFT": newPosition.x-=1; break;
                 case "UP": newPosition.y+=1; break;
                 case "DOWN": newPosition.y-=1; break;
+                case "COMBO_START": that.comboStartPosition = {x:that.mapPosition.x, y:that.mapPosition.y}; break;
+                case "COMBO_END": 
+                    var item = inventory.getItem(5);
+                    map.setItem( that.comboStartPosition, item ); 
+                    map.reRenderItems();
+                    break;
                 default:
                     console.log("unknown play action:", action);
                     break;