/ld27

To get this branch, use:
bzr branch /bzr/ld27
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
WinView = Subview:extend {
   onNew = function (self)
              local boxW = 300
              local boxH = 190
              local boxL = the.app.width / 2 - boxW / 2
              local boxT = the.app.height / 2 - boxH / 2
              local boxR = boxL + boxW
              local boxB = boxT + boxH

              self:add(Fill:new{
                          fill = {240,221,58},
                          x = boxL - 16,
                          y = boxT - 16,
                          width = boxW + 32,
                          height = boxH + 32,
                       })

              self:add(Fill:new{
                          fill = {166,44,217},
                          x = boxL,
                          y = boxT,
                          width = boxW,
                          height = boxH,
                       })

              self:add(Text:new{
                          text = 'You Win!',
                          x = boxL,
                          y = boxT + 16,
                          width = boxW,
                          font = 48,
                          align = 'center',
                          tint = {0,0,0}
                       })

              self:add(Text:new{
                          text = 'Press Q to quit',
                          x = boxL,
                          y = boxT + 90,
                          width = boxW,
                          font = 20,
                          align = 'center',
                          tint = {0,0,0}
                       })

              self:add(Text:new{
                          text = 'Any other key to keep exploring',
                          x = boxL,
                          y = boxT + 120,
                          width = boxW,
                          font = 20,
                          align = 'center',
                          tint = {0,0,0}
                       })


           end,
   onUpdate = function (self)
                 if the.keys:justPressed('q') then
                    if the.profiler then
                       the.profiler:stop()
                       local outfile = io.open( "profile.txt", "w+" )
                       the.profiler:report( outfile )
                       outfile:close()
                    end

                    the.app:quit()
                 elseif the.keys:allJustPressed() then
                    self:deactivate()
                 end
              end
}