<commit_before>module.exports = control

var Stream = require('stream').Stream

function control(gravity,opts) {
  return new DiscreteControl(gravity,opts)
}

function DiscreteControl(gravity,opts) {
  Stream.call(this)

  opts = opts || {}
  this._gravity=gravity

  this._action = 
  this._target = null

  this.readable =
  this.writable = true

  // the largest number of action that can be queued at a time 
  // (after exceeding this limit, additional actions are dropped)
  this.max_actions = opts.maxActions || 1024

  // bounds the movements of characters. 
  // (minx,maxx,miny,maxy,minz,maxz)
  // null indicates no bound
  this.bounds = opts.movementBounds || {'minx':null,'maxx':null,'miny':null,'maxy':null,'minz':null,'maxz':null}
  
  this._action_queue = []
  this.buffer = []
  this.paused = false
}

var cons = DiscreteControl
  , proto = cons.prototype = new Stream

proto.constructor = cons

proto.setMovementBounds = function(movementBounds){
  this.bounds = movementBounds || {}
}

proto.tick = function(dt) {
  if(!this._target) {
    return
  }

  // set up new action, if necessary
  this.setupAction()
  if (!this._action){
    return
  }

  // increment total elapsed time for this action
  this._action._elapsed += dt

  var target = this._target
    , action = this._action 
    , duration = action.duration 
    , height = action.height
    , radians = action.rotate<commit_msg>added api for setting game speed<commit_after>// modules
var Stream = require('stream').Stream
var duration_per_tick = 1

module.exports = function control(gravity,opts) {
  return new DiscreteControl(gravity,opts)
}

module.exports.setGameSpeed = function(percent){
  duration_per_tick = percent/100.0
}

function DiscreteControl(gravity,opts) {
  Stream.call(this)

  opts = opts || {}
  this._gravity=gravity

  this._action = 
  this._target = null

  this.readable =
  this.writable = true

  // the largest number of action that can be queued at a time 
  // (after exceeding this limit, additional actions are dropped)
  this.max_actions = opts.maxActions || 1024

  // bounds the movements of characters. 
  // (minx,maxx,miny,maxy,minz,maxz)
  // null indicates no bound
  this.bounds = opts.movementBounds || {'minx':null,'maxx':null,'miny':null,'maxy':null,'minz':null,'maxz':null}
  
  this._action_queue = []
  this.buffer = []
  this.paused = false
}

var cons = DiscreteControl
  , proto = cons.prototype = new Stream

proto.constructor = cons


proto.setMovementBounds = function(movementBounds){
  this.bounds = movementBounds || {}
}

proto.tick = function(dt) {
  if(!this._target) {
    return
  }

  // set up new action, if necessary
  this.setupAction()
  if (!this._action){
    return
  }

  // increment total elapsed time for this action
  this._action._elapsed += (dt * duration_per_tick)

  var target = this._target
    , action = this._action 
    , duration = action.duration 
    , height = action.height
    , radians = action.rotate
{'fraction_non_alphanumeric': 0.1196236559139785, 'fraction_numerical': 0.004368279569892473, 'mean_word_length': 3.55895865237366, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1228975', 'n_tokens_mistral': 972, 'n_tokens_neox': 915, 'n_words': 231}