Skip to content

Commit

Permalink
Moved debug logging out into it's own class
Browse files Browse the repository at this point in the history
  • Loading branch information
rbgrouleff committed Jan 12, 2012
1 parent 452ec4d commit 12a5a45
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
13 changes: 13 additions & 0 deletions test/debug.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module.exports = class Logger
constructor: ->
@ms = 0
@ticks = 0

tick: (ms) =>
if @ms + ms > 1000
console.log "FPS: #{@ticks}"
@ms = 0
@ticks = 0
else
@ms += ms
@ticks += 1
4 changes: 3 additions & 1 deletion test/test.coffee
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
window.Squash = require 'squash'
window.Logger = require 'debug'

screen = new Squash.Screen document.getElementById('canvas')

Expand All @@ -17,11 +18,12 @@ scene.addSprite sprite

window.timer = screen.getTimer()

timer.registerCallback new Logger().tick

@ticks = 0
@ms = 0
timer.registerCallback (timeSinceLastTick) =>
if @ms + timeSinceLastTick > 1000
console.log "FPS: #{@ticks}"
@ms = 0
@ticks = 0
sprite.move 10, 0
Expand Down

0 comments on commit 12a5a45

Please sign in to comment.