function Actor() {
	this.x = 0;
	this.y = 0;
	this.speedX = 0;
	this.speedY = 0;
	this.minSpeedX = null;
	this.maxSpeedX = null;
	this.minSpeedY = null;
	this.maxSpeedY = null;
	this.speedFactorX = 1;
	this.speedFactorY = 1;
	this.sprites = {};
	this.stepSize = 1;
	this.currentSprite = null;
	this.directionH = null;
	this.currentSpriteLabel = '';
	this.height = 1;
	this.width = 1;
}

Actor.prototype.setDirectionH = function(direction) {
	this.currentSprite.setDirectionH(direction);
	this.directionH = this.currentSprite.directionH;
	return this;
}

Actor.prototype.getWidth = function() {
	return this.width;
}

Actor.prototype.setWidth = function(width) {
	this.width = width;
	return this;
}

Actor.prototype.getHeight = function() {
	return this.height;
}

Actor.prototype.setHeight = function(height) {
	this.height = height;
	return this;
}

Actor.prototype.getDirectionH = function() {
	return this.directionH;
}

Actor.prototype.setMaxSpeedX = function(speed) {
	this.maxSpeedX = speed;
	return this;
}

Actor.prototype.setMinSpeedX = function(speed) {
	this.minSpeedX = speed;
	return this;
}

Actor.prototype.setMaxSpeedY = function(speed) {
	this.maxSpeedY = speed;
	return this;
}

Actor.prototype.setMinSpeedY = function(speed) {
	this.minSpeedY = speed;
	return this;
}

Actor.prototype.step = function() {
	return this.stepX().stepY();
}

Actor.prototype.stepX = function() {
	if (this.currentSprite) {
		this.setX(this.x + this.speedX * this.currentSprite.directionH);
	}
	return this;
}

Actor.prototype.stepY = function() {
	if (this.currentSprite) {
		this.setY(this.y + this.speedY * this.currentSprite.directionV);
	}
	return this;
}

Actor.prototype.setSpeedFactorX = function(factor) {
	this.speedFactorX = factor;
	return this;
}

Actor.prototype.setSpeedFactorY = function(factor) {
	this.speedFactorY = factor;
	return this;
}

Actor.prototype.accelerateX = function() {
	if (this.speedX >= this.maxSpeedX) {
		this.speedX = this.maxSpeedX;
	} else {
		this.speedX *= this.speedFactorX;
		if (this.speedX > this.maxSpeedX) {
			this.speedX = this.maxSpeedX;
		}
	}
	return this;
}

Actor.prototype.decelerateX = function() {
	if (this.speedX <= this.minSpeedX) {
		this.speedX = this.minSpeedX;
	} else {
		this.speedX /= this.speedFactorX;
		if (this.speedX < this.minSpeedX) {
			this.speedX = this.minSpeedX;
		}
	}
	return this;
}

Actor.prototype.accelerateY = function() {
	if (this.speedY >= this.maxSpeedY) {
		this.speedY = this.maxSpeedY;
	} else {
		this.speedY *= this.speedFactorY;
		if (this.speedY > this.maxSpeedY) {
			this.speedY = this.maxSpeedY;
		}
	}
	return this;
}

Actor.prototype.decelerateY = function() {
	if (this.speedY <= this.minSpeedY) {
		this.speedY = this.minSpeedY;
	} else {
		this.speedY /= this.speedFactorY;
		if (this.speedY < this.minSpeedY) {
			this.speedY = this.minSpeedY;
		}
	}
	return this;
}

Actor.prototype.stop = function() {
	this.speedX = this.speedY = 0;
	return this;
}

Actor.prototype.setPosition = function(x, y) {
	return this.setX(x).setY(y);
}

Actor.prototype.setX = function(value) {
	if (this.currentSprite) {
		this.currentSprite.setX(value);
		this.x = this.currentSprite.x;
	} else {
		this.x = value;
	}
	return this;
}

Actor.prototype.setY = function(value) {
	if (this.currentSprite) {
		this.currentSprite.setY(value);
		this.y = this.currentSprite.y;
	} else {
		this.Y = value;
	}
	return this;
}

Actor.prototype.syncCurrentSprite = function() {
	this.currentSprite.setX(this.x).setY(this.y).setDirectionH(this.directionH);
	return this;
}

Actor.prototype.setCurrentSprite = function(label) {
	if (this.sprites[label]) {
		this.currentSprite = this.sprites[label];
	}
	this.syncCurrentSprite();
	this.currentSpriteLabel = label;
	return this;
}

Actor.prototype.getCurrentSpriteLabel = function() {
	return this.currentSpriteLabel;
}

Actor.prototype.addSprite = function(label, sprite, inheritSpritePosition) {
	this.sprites[label] = sprite;
	if (!this.currentSprite) {
		this.currentSprite = this.sprites[label];
	}
	if (inheritSpritePosition) {
		this.x = this.currentSprite.x;
		this.y = this.currentSprite.y;
	} else {
		this.currentSprite.setPosition(this.x, this.y);
	}
	return this;
}

Actor.prototype.setStepSize = function(value) {
	this.stepSize = value;
	return this;
}

Actor.prototype.setSpeed = function(x, y) {
	return this.setSpeedX(x).setSpeedY(y);
}

Actor.prototype.setSpeedX = function(value) {
	this.speedX = value;
	if (this.maxSpeedX && this.speedX > this.maxSpeedX) {
		this.speedX = this.maxSpeedX;
	} else if (this.minSpeedX && this.speedX < this.minSpeedX) {
		this.speedX = this.minSpeedX;
	}
	return this;
}

Actor.prototype.setSpeedY = function(value) {
	this.speedY = value;
	if (this.maxSpeedY && this.speedY > this.maxSpeedY) {
		this.speedY = this.maxSpeedY;
	} else if (this.minSpeedY && this.speedY < this.minSpeedY) {
		this.speedY = this.minSpeedY;
	}
	return this;
}

Actor.prototype.draw = function() {
	this.currentSprite.draw();
	return this;
}

