"use strict";

var GO_Altar = function(checkevent,frame){
	this.sprite = new Sprite(GO_Altar.spriteSheet,"Altar"); // so all instances have different sprites
	this.sprite.collision_flags = 
		DEFINE_SPRITE_COLLISION_FLAGS.SPRITES_PASSIVE |
		DEFINE_SPRITE_COLLISION_FLAGS.SOLID;
	this.sprite.setBoundingBox(0,0,15,31);
	this.sprite.game_object = this; // no longer a generic GO

	this.controls = new Controls(); // just to init

	this.move_timer=0;

	this.sprite.frame = frame ? frame : 0;

	this._makeCheckable(checkevent);
};
GO_Altar.spriteImg = SDS_Load_Image("art/sheets/sprite/dragonaltar.png");
GO_Altar.spriteSheet = new TileSheet(4, 5, 2, 0, GO_Altar.spriteImg);

GO_Altar.prototype = new GameObject(
	new Sprite(
		GO_Altar.spriteSheet,
		"Altar"
	),
	"Altar"
	);

	GO_Altar.prototype.interactions = 
		DEFINE_GAMEOBJECT_INTERACTIONS.CONTROL;

	GO_Altar.prototype.Update = function(){
		if (this.controls.held.left){
			this.move_timer++;
			if (this.move_timer==1){
				this.sprite.move(-1,0,  this._heap.spriteMoveRes);
				this.move_timer=0;

				if (!this.sfx || this.sfx.name!="FX_grind"){
					this.sfx = new Chiptune("FX_grind",SDS.sfxchip);
				}
				if (!this.sfx.is_playing){
					this.sfx.play(true);
				}
			}
		}
		else{
			if (this.sfx && this.sfx.name=="FX_grind"){
				this.sfx.stop();
			}
		}
	};