95
95
the.bullets = Group:new()
96
96
the.mirrors = Group:new()
97
97
the.rocks = Group:new()
98
the.interface = Group:new()
100
99
the.bg = Tile:new{
101
100
image = 'data/stars3.png',
108
107
--the.player = CrystalPlayer:new{x=400,y=300}
109
108
the.player = SpacePlayer:new{x=1366,y=768}
110
109
self:add(the.player)
111
self:add(the.player.thrust)
113
111
--self:add(Enemy:new{x=400, y=300})
116
114
self:add(the.rockColliders)
117
115
self:add(the.mirrors)
118
116
self:add(the.rocks)
119
self:add(the.interface)
121
118
the.cursor = Cursor:new()
122
119
self:add(the.cursor)
124
121
the.score = Text:new{
127
122
width = the.app.width,
130
the.interface:add(the.score)
132
127
local hs = the.storage.data.highScore
133
128
local m = hs / 60
134
129
local s = hs % 60
136
131
the.highScore = Text:new{
139
132
width = the.app.width,
142
135
text = string.format('High Score: %d:%02d', m, s)
144
the.interface:add(the.highScore)
147
y = the.app.height / 2,
148
width = the.app.width,
154
the.interface:add(the.over)
157
the.instructions = Text:new{
158
y = the.app.height / 2 + 32,
159
width = the.app.width,
162
text = "Press Enter to start a new game\nPress Q to quit",
165
the.interface:add(the.instructions)
137
self:add(the.highScore)
167
139
love.mouse.setGrab(true)
168
140
love.mouse.setVisible(false)
175
147
self.gameStart = love.timer.getTime()
177
149
onUpdate = function(self, dt)
178
if the.player.active and love.timer.getTime() > self.lastRock + self.rockInterval then
150
if love.timer.getTime() > self.lastRock + self.rockInterval then
179
151
local unseenRock = nil
180
152
while not unseenRock do
181
153
local rock = Rock:new{
215
187
onEndFrame = function(self)
216
the.interface.translate.x = the.player.x - the.app.width / 2 + the.player.width / 2
217
the.interface.translate.y = the.player.y - the.app.height / 2 + the.player.height / 2
219
188
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
223
201
draw = function (self, x, y)
224
202
View.draw(self, x, y)
225
--love.graphics.print('FPS:' .. love.timer.getFPS(), 20, 20)
227
updateScore = function(self)
228
local t = love.timer.getTime() - self.gameStart
232
the.score.text = string.format('Score: %d:%02d', m, s)
233
--the.score.y = the.player.y - the.app.height / 2 + the.player.height
234
--the.score.x = the.player.x - the.app.width / 2 + the.player.width
236
--the.highScore.y = the.player.y - the.app.height / 2 + the.player.height
237
--the.highScore.x = the.player.x - the.app.width / 2
203
love.graphics.print('FPS:' .. love.timer.getFPS(), 20, 20)
241
207
MenuScreen = View:extend {
267
233
self.console:watch('the.app.width', 'the.app.width')
268
234
self.console:watch('the.app.height', 'the.app.height')
269
235
self.console:watch('num mirrors', '#the.mirrors.sprites')
270
self.console:watch('num rocks', '#the.rocks.sprites')
271
236
--self.console:watch('drawTook', 'the.drawTook')
273
238
-- back off that dark overlay a bit
277
242
onUpdate = function (self, dt)
278
if the.keys:justPressed('q') then
243
if the.keys:justPressed('escape') then
280
elseif the.keys:justPressed('return') then
281
self.view = GameView:new()
284
247
update = function (self, dt)