module.exports = function() {

  var Utilities = {};

  //Sets an objects speed based on the facing direction
  Utilities.setSpeed = function (object, facing, speed) {
    var direction = {
                      'n' : [0,-1],
                      'ne': [1,-1],
                      'e' : [1,0],
                      'se': [1,1],
                      's' : [0,1],
                      'sw': [-1,1],
                      'w' : [-1,0],
                      'nw': [-1,-1]
                    };
    object.body.velocity.x = direction[facing][0]*speed;
    object.body.velocity.y = direction[facing][1]*speed;
  }

  Utilities.setBulletSpeed = function (object, angleInRadians, speed) {
    var yModifier = Math.sin(angleInRadians),
        xModifier = Math.cos(angleInRadians);

    object.body.velocity.x = xModifier*speed;
    object.body.velocity.y = yModifier*speed;
  }

  Utilities.calculateRotation = function(game, object) {
    var deltaX = game.input.mousePointer.x - object.body.position.x,
        deltaY = game.input.mousePointer.y - object.body.position.y;

    return Math.atan2(deltaY, deltaX);
  }

  return Utilities;
}
module.exports = function() {

  var Utilities = {};

  //Sets an objects speed based on the facing direction
  Utilities.setSpeed = function (object, facing, speed) {
    var direction = {
                      'n' : [0,-1],
                      'ne': [1,-1],
                      'e' : [1,0],
                      'se': [1,1],
                      's' : [0,1],
                      'sw': [-1,1],
                      'w' : [-1,0],
                      'nw': [-1,-1]
                    };
    object.body.velocity.x = direction[facing][0]*speed;
    object.body.velocity.y = direction[facing][1]*speed;
  }

  Utilities.setBulletSpeed = function (object, angleInRadians, speed) {
    var yModifier = Math.sin(angleInRadians),
        xModifier = Math.cos(angleInRadians);

    object.body.velocity.x = xModifier*speed;
    object.body.velocity.y = yModifier*speed;
  }

  Utilities.calculateRotation = function(game, object) {
    var deltaX = game.input.mousePointer.x - (game.camera.width/2),
        deltaY = game.input.mousePointer.y - (game.camera.height/2)
    return Math.atan2(deltaY, deltaX);
  }

  return Utilities;
}
Update the mouse rotation