/traderous

To get this branch, use:
bzr branch http://9ix.org/bzr/traderous

« back to all changes in this revision

Viewing changes to main.lua

  • Committer: Josh C
  • Date: 2013-06-16 03:33:21 UTC
  • Revision ID: josh@9ix.org-20130616033321-6g7mgyxz3iyvt3un
move mouse to center when entering/exiting trade screen

Show diffs side-by-side

added added

removed removed

Lines of Context:
192
192
              self.gameStart = love.timer.getTime()
193
193
           end,
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),
 
203
                          velocity = {
 
204
                             x = math.random(-300, 300),
 
205
                             y = math.random(-300, 300),
 
206
                             rotation = math.random(-7, 7)
 
207
                          },
 
208
                          scale = math.random() + 0.5
 
209
                       }
 
210
 
 
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
 
214
                         unseenRock = rock
 
215
                        end
 
216
                    end
 
217
 
 
218
                    the.rocks:add(unseenRock)
 
219
 
 
220
                    self.lastRock = love.timer.getTime()
 
221
                 end
 
222
 
 
223
                 the.bullets:collide(the.rockColliders)
196
224
 
197
225
                 -- this should really go somewhere else...
198
226
                 for _, planet in ipairs(the.planets.sprites) do
 
227
                    local indx, indy
 
228
                    local pvec = vector.new(
 
229
                       planet.x - the.player.x + planet.width / 2,
 
230
                       planet.y - the.player.y + planet.height / 2 )
 
231
 
 
232
                    -- TODO: is there a better way to specify the
 
233
                    -- screen rectangle?
 
234
                    if planet:intersects(the.player.x - the.app.width / 2,
 
235
                                         the.player.y - the.app.height / 2,
 
236
                                         the.app.width,
 
237
                                         the.app.height) then
 
238
                       -- planet is on the screen
 
239
                       planet.indicator.visible = false
 
240
                    else
 
241
                       planet.indicator.visible = true
 
242
 
 
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)
 
246
                       else
 
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)
 
249
                       end
 
250
 
 
251
                       planet.indicator.x = the.player.x + indx
 
252
                       planet.indicator.y = the.player.y + indy
 
253
                    end
199
254
                 end
200
255
 
201
256
                 -- for _, mirror in ipairs(the.mirrors.sprites) do