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 }