﻿//! 爆発
var Expl = Class.create();
Expl.prototype = {
	initialize : function() {
		this.x      = 0;		// 座標（経度）
		this.y      = 0;		// 座標（緯度）
		this.frame  = 0;		// アニメフレーム
		this.elem   = null;		// キャラのエレメント
	},

	start : function(x, y, z) {
		Element.show(this.elem);
		this.x = x;
		this.y = y;
		this.frame = 0;
		this.kill = false;
		this.elem.style.zIndex = z;
	},

	end : function() {
		Element.hide(this.elem);
		this.kill = true;
	},

	update : function() {
		if (this.frame++ >= 12) this.end();
	},

	render : function() {
		var sx = toScreenX(this.x);
		var sy = toScreenY(this.y);
		this.clip = isClip(sx, sy);
		if (this.clip) this.end();
		else {
			var icon = (this.frame) * -16;
			this.elem.childNodes[0].style.left = icon + "px";
			this.elem.style.left = (sx-8) + "px";
			this.elem.style.top  = (sy-8) + "px";
		}
	}
};

function explode(x, y, z) {
	var e = explTask.pop();
	if (e) e.start(x, y, z);
}
