111
109
self:add(the.planets)
113
111
--the.player = CrystalPlayer:new{x=400,y=300}
114
the.player = SpacePlayer:new{x=the.bg.width / 2, y=the.bg.height / 2}
112
the.player = SpacePlayer:new{x=1366,y=768}
115
113
self:add(the.player)
116
114
self:add(the.player.thrust)
125
123
self:add(the.interface)
127
125
for _ = 1, math.random(6) do
128
local planet = Planet:new{
126
local planet = Tile:new{
127
image = 'data/planet1.png',
129
128
x = math.random(the.app.width / 2,
130
129
the.bg.width - the.app.width / 2),
131
130
y = math.random(the.app.height / 2,
192
196
self.gameStart = love.timer.getTime()
194
198
onUpdate = function(self, dt)
195
the.bullets:collide(the.planets)
199
if false and the.player.active and love.timer.getTime() > self.lastRock + self.rockInterval then
200
local unseenRock = nil
201
while not unseenRock do
202
local rock = Rock:new{
203
x = math.random(the.app.width / 2,
204
the.bg.width - the.app.width / 2),
205
y = math.random(the.app.height / 2,
206
the.bg.height - the.app.height / 2),
208
x = math.random(-300, 300),
209
y = math.random(-300, 300),
210
rotation = math.random(-7, 7)
212
scale = math.random() + 0.5
215
local rockToPlayer = util.shortestVector(rock, the.player)
216
if math.abs(rockToPlayer.x) > the.app.width / 2 + rock.width * rock.scale and
217
math.abs(rockToPlayer.y) > the.app.height / 2 + rock.height * rock.scale then
222
the.rocks:add(unseenRock)
224
self.lastRock = love.timer.getTime()
227
the.bullets:collide(the.rockColliders)
197
229
-- this should really go somewhere else...
198
230
for _, planet in ipairs(the.planets.sprites) do
232
local pvec = vector.new(
233
planet.x - the.player.x + planet.width / 2,
234
planet.y - the.player.y + planet.height / 2 )
236
-- TODO: is there a better way to specify the
238
if planet:intersects(the.player.x - the.app.width / 2,
239
the.player.y - the.app.height / 2,
242
-- planet is on the screen
243
planet.indicator.visible = false
245
planet.indicator.visible = true
247
if math.abs(pvec.x) / math.abs(pvec.y) > the.app.width / the.app.height then
248
indx = the.app.width / 2 * util.signOf(pvec.x) + 8
249
indy = the.app.width / 2 * pvec.y / math.abs(pvec.x)
251
indy = the.app.height / 2 * util.signOf(pvec.y) + 8
252
indx = the.app.height / 2 * pvec.x / math.abs(pvec.y)
255
planet.indicator.x = the.player.x + indx
256
planet.indicator.y = the.player.y + indy
201
260
-- for _, mirror in ipairs(the.mirrors.sprites) do
254
313
self.view = GameView:new()
315
-- should fail silently if it can't go to fullscreen...
316
love.graphics.toggleFullscreen()
257
319
self.console:watch('VERSION', 'VERSION')
258
320
self.console:watch('updateTook', 'the.updateTook')