/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-16 02:41:58 UTC
  • Revision ID: josh@9ix.org-20130516024158-d5jtkfvd2qw709xo
record high scores

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
 
4
4
require 'zoetrope'
5
5
vector = require 'vector'
6
 
--inspect = require 'inspect'
7
6
 
8
7
require 'group'
9
8
 
147
146
              self.gameStart = love.timer.getTime()
148
147
           end,
149
148
   onUpdate = function(self, dt)
150
 
                 if the.player.active and love.timer.getTime() > self.lastRock + self.rockInterval then
 
149
                 if love.timer.getTime() > self.lastRock + self.rockInterval then
151
150
                    local unseenRock = nil
152
151
                    while not unseenRock do
153
152
                       local rock = Rock:new{
176
175
                 end
177
176
 
178
177
                 the.bullets:collide(the.rockColliders)
179
 
 
180
 
                 -- for _, mirror in ipairs(the.mirrors.sprites) do
181
 
                 --    if not mirror.of then
182
 
                 --       print('mirror:' .. inspect(mirror))
183
 
                 --       error('mirror OF NOTHING')
184
 
                 --    end
185
 
                 -- end
186
178
              end,
187
179
   onEndFrame = function(self)
188
180
                   if the.player.active then
189
 
                      self:updateScore()
 
181
                      local t = love.timer.getTime() - self.gameStart
 
182
                      local m = t / 60
 
183
                      local s = t % 60
 
184
 
 
185
                      the.score.text = string.format('Score: %d:%02d', m, s)
 
186
                      the.score.y = the.player.y - the.app.height / 2 + the.player.height
 
187
                      the.score.x = the.player.x - the.app.width / 2
190
188
                   end
 
189
 
 
190
                   the.highScore.y = the.player.y - the.app.height / 2 + the.player.height
 
191
                   the.highScore.x = the.player.x - the.app.width / 2
191
192
                end,
192
193
   draw = function (self, x, y)
193
194
             View.draw(self, x, y)
194
195
             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
 
196
          end
208
197
}
209
198
 
210
199
MenuScreen = View:extend {
235
224
                 self.console:watch('the.player.y', 'the.player.y')
236
225
                 self.console:watch('the.app.width', 'the.app.width')
237
226
                 self.console:watch('the.app.height', 'the.app.height')
238
 
                 self.console:watch('num mirrors', '#the.mirrors.sprites')
239
 
                 self.console:watch('num rocks', '#the.rocks.sprites')
240
227
                 --self.console:watch('drawTook', 'the.drawTook')
241
228
 
242
229
                 -- back off that dark overlay a bit