/ld26

To get this branch, use:
bzr branch /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
38
39
40
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.player.active = false
                           the.app.view:fade({0,0,0}):andThen(function()
                              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
                           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
}