"use strict";
/* an arbitrary pile of bones built from tiles */
var Deco_Bonepile = function(grid){
	this.grid = grid ? grid : [
		[1,3],
		[5,6]
	];

	// using the map editor to lay these out is convenient
	// except for the fact that it returns strings
	for (this._heap.r=0; this._heap.r<this.grid.length; this._heap.r++){
		for (this._heap.c=0; this._heap.c<this.grid[this._heap.r].length; this._heap.c++){
			if (typeof(this.grid[this._heap.r][this._heap.c])==='string'){
				this.grid[this._heap.r][this._heap.c] = parseInt(this.grid[this._heap.r][this._heap.c],4);
			}
		}
	}
}

Deco_Bonepile.prototype = new Decoration(
	new TileSheet(
		4, 4, 2, 1, 
		SDS_Load_Image("art/sheets/decoration/bones.png")
	),
	"Bonepile");

Deco_Bonepile.prototype.drawIntoCanvas = function(canvas){
		if (this.tile_sheet){
			for (this._heap.r=0; this._heap.r<this.grid.length; this._heap.r++){
				for (this._heap.c=0; this._heap.c<this.grid[this._heap.r].length; this._heap.c++){
					this.tile_sheet.drawIntoCanvas(
						canvas,
						this.grid[this._heap.r][this._heap.c],
						this.x + this._heap.c*this.tile_sheet.tile_pixel_width,
						this.y + this._heap.r*this.tile_sheet.tile_pixel_height
						);
				}
			}
		}
	};
