/ld26

To get this branch, use:
bzr branch http://9ix.org/bzr/ld26
19 by Josh C
inventory (and a flower)
1
Inventory = Class:extend {
2
   items = {},
35 by Josh C
troll
3
   had = {},
19 by Josh C
inventory (and a flower)
4
   visible = true,
47 by Josh C
inventory stack bug
5
   nitems = 0,
19 by Josh C
inventory (and a flower)
6
   add = function(self, item)
7
            self.items[item.name] = item
37 by Josh C
really basic feedback that your inventory changed
8
            the.app.view:flash({0,255,0})
47 by Josh C
inventory stack bug
9
10
            item.invTile.y = 10
11
            item.invTile.x = 50 * self.nitems
12
13
            self.nitems = self.nitems + 1
19 by Josh C
inventory (and a flower)
14
         end,
35 by Josh C
troll
15
   remove = function(self, name)
16
               self.had[name] = self.items[name]
17
               self.items[name] = nil
47 by Josh C
inventory stack bug
18
               self.nitems = self.nitems - 1
19
20
               local newindex = 0
21
               for _, item in pairs(self.items) do
22
                  item.invTile.x = 50 * newindex
23
                  newindex = newindex + 1
24
               end
35 by Josh C
troll
25
            end,
19 by Josh C
inventory (and a flower)
26
   draw = function(self)
27
             for _, item in pairs(self.items) do
28
                item.invTile:draw()
29
             end
30
          end
31
}
32
33
the.inventory = Inventory:new()