95
95
the.bullets = Group:new()
96
96
the.mirrors = Group:new()
97
97
the.rocks = Group:new()
98
the.interface = Group:new()
99
100
the.bg = Tile:new{
100
101
image = 'data/stars3.png',
114
115
self:add(the.rockColliders)
115
116
self:add(the.mirrors)
116
117
self:add(the.rocks)
118
self:add(the.interface)
118
120
the.cursor = Cursor:new()
119
121
self:add(the.cursor)
121
123
the.score = Text:new{
122
126
width = the.app.width,
129
the.interface:add(the.score)
127
131
local hs = the.storage.data.highScore
128
132
local m = hs / 60
129
133
local s = hs % 60
131
135
the.highScore = Text:new{
132
138
width = the.app.width,
135
141
text = string.format('High Score: %d:%02d', m, s)
137
self:add(the.highScore)
143
the.interface:add(the.highScore)
146
y = the.app.height / 2,
147
width = the.app.width,
153
the.interface:add(the.over)
156
the.instructions = Text:new{
157
y = the.app.height / 2 + 32,
158
width = the.app.width,
161
text = "Press Enter to start a new game\nPress Q to quit",
164
the.interface:add(the.instructions)
139
166
love.mouse.setGrab(true)
140
167
love.mouse.setVisible(false)
187
214
onEndFrame = function(self)
215
the.interface.translate.x = the.player.x - the.app.width / 2 + the.player.width / 2
216
the.interface.translate.y = the.player.y - the.app.height / 2 + the.player.height / 2
188
218
if the.player.active then
189
local t = love.timer.getTime() - self.gameStart
193
the.score.text = string.format('Score: %d:%02d', m, s)
194
the.score.y = the.player.y - the.app.height / 2 + the.player.height
195
the.score.x = the.player.x - the.app.width / 2
198
the.highScore.y = the.player.y - the.app.height / 2 + the.player.height
199
the.highScore.x = the.player.x - the.app.width / 2
201
222
draw = function (self, x, y)
202
223
View.draw(self, x, y)
203
love.graphics.print('FPS:' .. love.timer.getFPS(), 20, 20)
224
--love.graphics.print('FPS:' .. love.timer.getFPS(), 20, 20)
226
updateScore = function(self)
227
local t = love.timer.getTime() - self.gameStart
231
the.score.text = string.format('Score: %d:%02d', m, s)
232
--the.score.y = the.player.y - the.app.height / 2 + the.player.height
233
--the.score.x = the.player.x - the.app.width / 2 + the.player.width
235
--the.highScore.y = the.player.y - the.app.height / 2 + the.player.height
236
--the.highScore.x = the.player.x - the.app.width / 2
207
240
MenuScreen = View:extend {