/ld26

To get this branch, use:
bzr branch http://9ix.org/bzr/ld26
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
Transition = Group:extend {
   visible = false,
   onNew = function(self)
      local t = self
      -- NOTE: X/Y will fail if you init Transition before Player!
      box = Fill:new{x = self.x, y = self.y,
                     height = self.height or the.player.height,
                     width = self.width or the.player.width,
                     fill = {0, 255, 0},
                     onCollide = function(self, other, xOl, yOl)
                        -- (sanity check)
                        if other == the.player then
                           --print("Sending to "..t.target)

                           the.app.view = GameView:new{level = t.target}

                           if t.targetX or t.targetY then
                              the.player.x = t.targetX
                              the.player.y = t.targetY
                           end
                        else
                           print("Colliding with: "..other)
                        end
                     end
                  }
      self:add(box)
      self:add(Text:new{x = self.x, y = self.y,
                        text = "T"
                     })
     
      -- make sure collision doesn't think group is a sprite
      self.x, self.y, self.width, self.height = nil, nil, nil, nil
   end,
   onUpdate = function(self, dt)
                 self.visible = DEBUG and the.console.visible
              end
}