/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-20 16:51:19 UTC
  • Revision ID: josh@9ix.org-20130520165119-mkjh7d9408e6ig0u
extract updating score.  update score again when you calc high score - 
should mitigate a bug I saw happen when thor played that put final score 
+ high score out of sync

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 love.timer.getTime() > self.lastRock + self.rockInterval then
 
150
                 if the.player.active and 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
 
                      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
 
189
                      self:updateScore()
196
190
                   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
200
191
                end,
201
192
   draw = function (self, x, y)
202
193
             View.draw(self, x, y)
203
194
             love.graphics.print('FPS:' .. love.timer.getFPS(), 20, 20)
204
 
          end
 
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
205
208
}
206
209
 
207
210
MenuScreen = View:extend {
233
236
                 self.console:watch('the.app.width', 'the.app.width')
234
237
                 self.console:watch('the.app.height', 'the.app.height')
235
238
                 self.console:watch('num mirrors', '#the.mirrors.sprites')
 
239
                 self.console:watch('num rocks', '#the.rocks.sprites')
236
240
                 --self.console:watch('drawTook', 'the.drawTook')
237
241
 
238
242
                 -- back off that dark overlay a bit