// explosion.js // An explosion and a cleft on a map. var ebicon = new GIcon; ebicon.shadow = "images/dummy_shadow.png"; ebicon.iconSize = new GSize(32, 32); ebicon.shadowSize = new GSize(1, 1); ebicon.iconAnchor = new GPoint(16, 16); var eicons = new Array; for (var i = 0; i < 6; i++) { var eicon = new GIcon(ebicon); eicon.image = "images/explosion" + i + ".png"; eicons.push(eicon); } var cicon = new GIcon(ebicon); cicon.image = "images/cleft.png"; function Explosion() { this.onGround; this.cnt; this.exists = false; this.marker = new GMarker( new GPoint(mapManager.centerX, mapManager.centerY), eicons[0]); this.set = function(point, onGround) { if (this.exists) return; this.marker.point.x = point.x; this.marker.point.y = point.y; this.onGround = onGround; this.cnt = 0; this.exists = true; map.addOverlay(this.marker); this.updateMarker(); } this.updateMarker = function() { this.marker.remove(); this.marker.icon = eicons[this.cnt]; this.marker.initialize(map); this.marker.redraw(true); } this.update = function() { if (!this.exists) return; this.cnt++; if (this.cnt == 3 && this.onGround) { var c = getCleftInstance(); if (c != null) c.set(this.marker.point); } else if (this.cnt > 5) { this.exists = false; map.removeOverlay(this.marker); return; } this.updateMarker(); } } function Cleft() { this.exists = false; this.marker = new GMarker( new GPoint(mapManager.centerX, mapManager.centerY), cicon); this.set = function(point) { this.marker.point.x = point.x; this.marker.point.y = point.y; this.exists = true; map.addOverlay(this.marker); } this.update = function() { if (!this.exists) return; if (this.marker.point.x < mapManager.bounds.minX || this.marker.point.x > mapManager.bounds.maxX || this.marker.point.y < mapManager.bounds.minY || this.marker.point.y > mapManager.bounds.maxY) { this.exists = false; map.removeOverlay(this.marker); return; } } }