/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-05-18 00:09:56 UTC
  • Revision ID: josh@9ix.org-20130518000956-s9717aensfsq1b3c
fix double-removing sprites (and subsequent zombie mirror bullets).  
also lots of debug stuff.

Show diffs side-by-side

added added

removed removed

Lines of Context:
147
147
              self.gameStart = love.timer.getTime()
148
148
           end,
149
149
   onUpdate = function(self, dt)
150
 
                 if the.player.active and love.timer.getTime() > self.lastRock + self.rockInterval then
 
150
                 if love.timer.getTime() > self.lastRock + self.rockInterval then
151
151
                    local unseenRock = nil
152
152
                    while not unseenRock do
153
153
                       local rock = Rock:new{
186
186
              end,
187
187
   onEndFrame = function(self)
188
188
                   if the.player.active then
189
 
                      self:updateScore()
 
189
                      local t = love.timer.getTime() - self.gameStart
 
190
                      local m = t / 60
 
191
                      local s = t % 60
 
192
 
 
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
190
196
                   end
 
197
 
 
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
191
200
                end,
192
201
   draw = function (self, x, y)
193
202
             View.draw(self, x, y)
194
203
             love.graphics.print('FPS:' .. love.timer.getFPS(), 20, 20)
195
 
          end,
196
 
   updateScore = function(self)
197
 
                    local t = love.timer.getTime() - self.gameStart
198
 
                    local m = t / 60
199
 
                    local s = t % 60
200
 
 
201
 
                    the.score.text = string.format('Score: %d:%02d', m, s)
202
 
                    the.score.y = the.player.y - the.app.height / 2 + the.player.height
203
 
                    the.score.x = the.player.x - the.app.width / 2
204
 
 
205
 
                    the.highScore.y = the.player.y - the.app.height / 2 + the.player.height
206
 
                    the.highScore.x = the.player.x - the.app.width / 2
207
 
                 end
 
204
          end
208
205
}
209
206
 
210
207
MenuScreen = View:extend {
236
233
                 self.console:watch('the.app.width', 'the.app.width')
237
234
                 self.console:watch('the.app.height', 'the.app.height')
238
235
                 self.console:watch('num mirrors', '#the.mirrors.sprites')
239
 
                 self.console:watch('num rocks', '#the.rocks.sprites')
240
236
                 --self.console:watch('drawTook', 'the.drawTook')
241
237
 
242
238
                 -- back off that dark overlay a bit