IsoRes.Tiles.Basic = function(options){
	_.extend(this,{style:'grass'},options);
	this.tileName = 'Basic';
}
IsoRes.Tiles.Basic.prototype = {
	stackable : true,
	changed : true,
	styles: [],
	sprites : [],
	renderer : 'tile', // Default renderer only places a tile-shaped, static image.
	tileTick : 0,
	sx : 0,
	sy : 0,
	w : 1,
	h: 1,
	getStyle : function(){
		return this.style;
	},
	prepareTile : function(){
		this.image = new Image();
		console.log(this.format);
		this.image.width=256;
		this.image.height=256;
		this.image.src = this.parent.getImageUri(this.tileName,this.getStyle(),'tiles',this.format);
		
		// Adjust the renderer if required.
		if(typeof this.sprites[this.style] != 'undefined') { 
			this.sprited = true;
			this.renderer = 'tileSprite';
		}
		return this;
	},
	
	getSpriteNumber : function(gameTime,totalSprites, fps){
		var spriteNum = Math.floor((gameTime % ((totalSprites+1) /fps))*fps);
		return spriteNum;
	},
	
	prepareSprite : function(gameTime){
		var spriteNumber = this.getSpriteNumber(gameTime, this.sprites[this.style], 2);
		this.sx = this.w * spriteNumber;
	},
	
	drawTile : function(gameTime){
		// If something on the tile has changed, update it.
		if(this.changed) {
			this.prepareTile();
			this.changed = false;
		}
		
		if(this.sprited) {
			this.prepareSprite(gameTime);
		}
		
		return this;
	},
	
	/**
	 * Can the given tile stack on top of this one?
	 */
	canStack : function(tile){
		if(typeof this.stackable == 'boolean') return this.stackable; // No arguing this.
		
		if(this.stackable.indexOf(tile.tileName) != -1){
			return true;
		}
		
		//~ console.log('The tile '+tile.tileName+' does not stack on ' + this.tileName+' (placed on level '+this.z+')');
		return false;
		
	},
	
	save : function(){
		return this;
	}
}
