"use strict";
/* a series of moving waves.  speed is in px per 2^perframes frames */
var Deco_Waves = function(copies,speed,perframes){
	this.copies = copies ? copies : 4;
	this.offset = 0;
	this.speed = (typeof(speed)!=='undefined') ? speed : 1;
	this.perframes = perframes ? perframes : 0;
}

Deco_Waves.prototype = new Decoration(
	new TileSheet(
		5, 3, 0, 0, 
		SDS_Load_Image("art/sheets/decoration/wave.png")
	),
	"Wave");

Deco_Waves.prototype.animate = function(){
		this.offset = this.offset+this.speed;
		if (this.offset<0) this.offset += this.tile_sheet.tile_pixel_width<<this.perframes;
		if (this.offset >= this.tile_sheet.tile_pixel_width<<this.perframes) this.offset -= this.tile_sheet.tile_pixel_width<<this.perframes;
	}

Deco_Waves.prototype.drawIntoCanvas = function(canvas){
		if (this.tile_sheet){
			this._heap.drawpoint = this.x + (this.offset>>this.perframes);
			for (this._heap.i=-1; this._heap.i<this.copies; this._heap.i++){
				this.tile_sheet.drawIntoCanvas(
					canvas,
					0,
					this._heap.drawpoint + this._heap.i*this.tile_sheet.tile_pixel_width,
					this.y);
			}
		}
	};
