shell.js
function tick(shell) {
  var skip = hrtime() + shell.frameSkip
    , pCount = shell._pressCount
    , rCount = shell._releaseCount
    , i, s, t
    , tr = shell._tickRate
    , n = keyNames.length
  while(!shell._paused &&
        hrtime() >= shell._lastTick + tr) {
    
    //Skip frames if we are over budget
    if(hrtime() > skip) {
      shell._lastTick = hrtime() + tr
      return
    }
    
    //Tick the game
    s = hrtime()
    shell.emit("tick")
    t = hrtime()
    shell.tickTime = t - s
    
    //Update counters and time
    ++shell.tickCount
    shell._lastTick += tr
    
    //Shift input state
    for(i=0; i<n; ++i) {
      pCount[i] = rCount[i] = 0
    }
    if(shell._pointerLockActive) {
      shell.prevMouseX = shell.mouseX = shell.width>>1
      shell.prevMouseY = shell.mouseY = shell.height>>1
    } else {
      shell.prevMouseX = shell.mouseX
      shell.prevMouseY = shell.mouseY
    }
    shell.scroll[0] = shell.scroll[1] = shell.scroll[2] = 0
  }
}
function tick(shell) {
  var skip = hrtime() + shell.frameSkip
    , pCount = shell._pressCount
    , rCount = shell._releaseCount
    , i, s, t
    , tr = shell._tickRate
    , n = keyNames.length
  while(!shell._paused &&
        hrtime() >= shell._lastTick + tr) {
    
    //Skip frames if we are over budget
    if(hrtime() > skip) {
      shell._lastTick = hrtime() + tr
      return
    }
    
    //Tick the game
    s = hrtime()
    shell.emit("tick")
    t = hrtime()
    shell.tickTime = t - s
    
    //Update counters and time
    ++shell.tickCount
    shell._lastTick += tr
    
    //Shift input state
    for(i=0; i<n; ++i) {
      pCount[i] = rCount[i] = 0
    }
    if(shell._pointerLockActive) {
      shell.prevMouseX = shell.mouseX = shell.width>>1
      shell.prevMouseY = shell.mouseY = shell.height>>1
    } else {
      shell.prevMouseX = shell.mouseX
      shell.prevMouseY = shell.mouseY
    }
    shell.scroll[0] = shell.scroll[1] = shell.scroll[2] = 0
  }
}
function tick ( shell ) { var skip = hrtime ( ) + shell . frameSkip , pCount = shell . _pressCount , rCount = shell . _releaseCount , i , s , t , tr = shell . _tickRate , n = keyNames . length while ( ! shell . _paused && hrtime ( ) >= shell . _lastTick + tr ) { //Skip frames if we are over budget if ( hrtime ( ) > skip ) { shell . _lastTick = hrtime ( ) + tr return } //Tick the game s = hrtime ( ) shell . emit ( "tick" ) t = hrtime ( ) shell . tickTime = t - s //Update counters and time ++ shell . tickCount shell . _lastTick += tr //Shift input state for ( i = 0 ; i < n ; ++ i ) { pCount [ i ] = rCount [ i ] = 0 } if ( shell . _pointerLockActive ) { shell . prevMouseX = shell . mouseX = shell . width >> 1 shell . prevMouseY = shell . mouseY = shell . height >> 1 } else { shell . prevMouseX = shell . mouseX shell . prevMouseY = shell . mouseY } shell . scroll [ 0 ] = shell . scroll [ 1 ] = shell . scroll [ 2 ] = 0 } }
Ticks the game state one update
Ticks the game state one update