/traderous

To get this branch, use:
bzr branch /bzr/traderous
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
73
74
GameOver = Group:extend {
   onNew = function (self)
              self.died = love.timer.getTime()

              local boxW = 200
              local boxH = 70
              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.boxT = boxT

              local lh = 26 -- line height

              self:add(Fill:new{
                          fill = {255,255,255},
                          x = boxL - 1,
                          y = boxT - 1,
                          width = boxW + 2,
                          height = boxH + 2,
                       })

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

              self:add(Text:new{
                          text = 'You died',
                          x = boxL,
                          y = boxT + 10,
                          width = boxW,
                          font = 16,
                          align = 'center'
                       })

              self.timer = Text:new{
                 text = 'Respawning in ...',
                 x = boxL,
                 y = boxT + 40,
                 width = boxW,
                 font = 16,
                 align = 'center'
              }
              self:add(self.timer)
           end,
   onUpdate = function (self)
                 local time = math.floor(self.died + 5.9 - love.timer.getTime())

                 self.timer.text = 'Respawning in ' .. time .. '...'

                 if time <= 0 then
                    local m = math.ceil(the.player.money * .8)
                    the.player = SpacePlayer:new{
                       x = the.storage.data.player.x,
                       y = the.storage.data.player.y,
                       money = m,
                       cargoSpace = the.storage.data.player.cargoSpace
                    }
                    the.app.view:add(the.player)
                    the.app.view:add(the.player.thrust)
                    the.app.view:add(the.player.shield)

                    the.app.view.focus = the.player

                    love.mouse.setPosition(the.app.width / 2, the.app.height / 2)

                    the.interface:remove(self)
                 end
              end
}