192
192
self.gameStart = love.timer.getTime()
194
194
onUpdate = function(self, dt)
195
the.bullets:collide(the.planets)
195
if false and the.player.active and love.timer.getTime() > self.lastRock + self.rockInterval then
196
local unseenRock = nil
197
while not unseenRock do
198
local rock = Rock:new{
199
x = math.random(the.app.width / 2,
200
the.bg.width - the.app.width / 2),
201
y = math.random(the.app.height / 2,
202
the.bg.height - the.app.height / 2),
204
x = math.random(-300, 300),
205
y = math.random(-300, 300),
206
rotation = math.random(-7, 7)
208
scale = math.random() + 0.5
211
local rockToPlayer = util.shortestVector(rock, the.player)
212
if math.abs(rockToPlayer.x) > the.app.width / 2 + rock.width * rock.scale and
213
math.abs(rockToPlayer.y) > the.app.height / 2 + rock.height * rock.scale then
218
the.rocks:add(unseenRock)
220
self.lastRock = love.timer.getTime()
223
the.bullets:collide(the.rockColliders)
197
225
-- this should really go somewhere else...
198
226
for _, planet in ipairs(the.planets.sprites) do
228
local pvec = vector.new(
229
planet.x - the.player.x + planet.width / 2,
230
planet.y - the.player.y + planet.height / 2 )
232
-- TODO: is there a better way to specify the
234
if planet:intersects(the.player.x - the.app.width / 2,
235
the.player.y - the.app.height / 2,
238
-- planet is on the screen
239
planet.indicator.visible = false
241
planet.indicator.visible = true
243
if math.abs(pvec.x) / math.abs(pvec.y) > the.app.width / the.app.height then
244
indx = (the.app.width / 2 - 10) * util.signOf(pvec.x) + 8
245
indy = (the.app.width / 2 - 10) * pvec.y / math.abs(pvec.x)
247
indy = (the.app.height / 2 - 10) * util.signOf(pvec.y) + 8
248
indx = (the.app.height / 2 - 10) * pvec.x / math.abs(pvec.y)
251
planet.indicator.x = the.player.x + indx
252
planet.indicator.y = the.player.y + indy
201
256
-- for _, mirror in ipairs(the.mirrors.sprites) do