/traderous

To get this branch, use:
bzr branch /bzr/traderous
84 by Josh C
game over timer & penalty
1
GameOver = Group:extend {
2
   onNew = function (self)
3
              self.died = love.timer.getTime()
4
5
              local boxW = 200
6
              local boxH = 70
7
              local boxL = the.app.width / 2 - boxW / 2
8
              local boxT = the.app.height / 2 - boxH / 2
9
              local boxR = boxL + boxW
10
              local boxB = boxT + boxH
11
              self.boxT = boxT
12
13
              local lh = 26 -- line height
14
15
              self:add(Fill:new{
16
                          fill = {255,255,255},
17
                          x = boxL - 1,
18
                          y = boxT - 1,
19
                          width = boxW + 2,
20
                          height = boxH + 2,
21
                       })
22
23
              self:add(Fill:new{
24
                          fill = {0,0,0},
25
                          x = boxL,
26
                          y = boxT,
27
                          width = boxW,
28
                          height = boxH,
29
                       })
30
31
              self:add(Text:new{
32
                          text = 'You died',
33
                          x = boxL,
34
                          y = boxT + 10,
35
                          width = boxW,
36
                          font = 16,
37
                          align = 'center'
38
                       })
39
40
              self.timer = Text:new{
41
                 text = 'Respawning in ...',
42
                 x = boxL,
43
                 y = boxT + 40,
44
                 width = boxW,
45
                 font = 16,
46
                 align = 'center'
47
              }
48
              self:add(self.timer)
49
           end,
50
   onUpdate = function (self)
85 by Josh C
because it's funny
51
                 local time = math.floor(self.died + 5.9 - love.timer.getTime())
84 by Josh C
game over timer & penalty
52
53
                 self.timer.text = 'Respawning in ' .. time .. '...'
54
55
                 if time <= 0 then
56
                    local m = math.ceil(the.player.money * .8)
57
                    the.player = SpacePlayer:new{
58
                       x = the.storage.data.player.x,
59
                       y = the.storage.data.player.y,
60
                       money = m,
61
                       cargoSpace = the.storage.data.player.cargoSpace
62
                    }
63
                    the.app.view:add(the.player)
64
                    the.app.view:add(the.player.thrust)
65
                    the.app.view:add(the.player.shield)
66
67
                    the.app.view.focus = the.player
68
90 by Josh C
recenter mouse on respawn
69
                    love.mouse.setPosition(the.app.width / 2, the.app.height / 2)
70
84 by Josh C
game over timer & penalty
71
                    the.interface:remove(self)
72
                 end
73
              end
74
}