mirror of
https://github.com/Febbweiss/sis.git
synced 2026-03-04 22:25:35 +00:00
Feature: add hero's explosion animation
This commit is contained in:
@@ -90,10 +90,9 @@ Game = {
|
|||||||
if( Game.ship.lives > 0 ) {
|
if( Game.ship.lives > 0 ) {
|
||||||
var _this = Game.ship;
|
var _this = Game.ship;
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
|
Game.ship.respawn();
|
||||||
Game.running = true;
|
Game.running = true;
|
||||||
$("#hero").children().show();
|
}, 5000);
|
||||||
_this.health = 1;
|
|
||||||
}, 2000);
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Game.game_over();
|
Game.game_over();
|
||||||
@@ -293,13 +292,15 @@ Game = {
|
|||||||
var weapon = $(this)[0].weapon;
|
var weapon = $(this)[0].weapon;
|
||||||
$(this).y(weapon.directionY * weapon.speed, true);
|
$(this).y(weapon.directionY * weapon.speed, true);
|
||||||
$(this).x(weapon.directionX * weapon.speed, true);
|
$(this).x(weapon.directionX * weapon.speed, true);
|
||||||
var collisions = $(this).collision("#ship,."+$.gQ.groupCssClass);
|
// var collisions = $(this).collision("#ship,."+$.gQ.groupCssClass);
|
||||||
|
try {
|
||||||
|
var collisions = $(this).collision("#actors,#hero,#ship");
|
||||||
if( collisions.length > 0 ) {
|
if( collisions.length > 0 ) {
|
||||||
collisions.each( function() {
|
|
||||||
Game.hit();
|
Game.hit();
|
||||||
});
|
|
||||||
this.remove();
|
this.remove();
|
||||||
}
|
}
|
||||||
|
}catch(e) {
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -299,8 +299,10 @@ function CornWeapon() {
|
|||||||
var mediumAlien = getAliensMidHeight();
|
var mediumAlien = getAliensMidHeight();
|
||||||
|
|
||||||
if( shot.y() < mediumAlien ) {
|
if( shot.y() < mediumAlien ) {
|
||||||
var explosion = EXPLOSIONS.SMALL[0];
|
var x = shot.x(),
|
||||||
$("#shipShots").addSprite("cornExplosion", {width: explosion.width, height: explosion.height, posx: shot.x() - explosion.width / 2, posy: shot.y() - explosion.height / 2});
|
y = shot.y(),
|
||||||
|
explosion = EXPLOSIONS.SMALL[0];
|
||||||
|
$("#shipShots").addSprite("cornExplosion", {width: explosion.width, height: explosion.height, posx: x - explosion.width / 2, posy: y - explosion.height / 2});
|
||||||
explosionSmall($("#cornExplosion"), function() {$("#cornExplosion").remove()});
|
explosionSmall($("#cornExplosion"), function() {$("#cornExplosion").remove()});
|
||||||
shot.remove();
|
shot.remove();
|
||||||
|
|
||||||
@@ -314,7 +316,7 @@ function CornWeapon() {
|
|||||||
if( Math.abs(sin) < 0.01) {
|
if( Math.abs(sin) < 0.01) {
|
||||||
sin = 0;
|
sin = 0;
|
||||||
}
|
}
|
||||||
shipShots.addSprite( "shotCorn" + i, { posx : shot.x() + 5 * cos, posy : shot.y() + 5 * sin, width: 2, height: 2});
|
shipShots.addSprite( "shotCorn" + i, { posx : x + 5 * cos, posy : y + 5 * sin, width: 2, height: 2});
|
||||||
var shotCorn = $("#shotCorn" + i);
|
var shotCorn = $("#shotCorn" + i);
|
||||||
shotCorn.addClass("shipShot").addClass("shotCorn");
|
shotCorn.addClass("shipShot").addClass("shotCorn");
|
||||||
$("#shotCorn" + i)[0].weapon = $.extend({
|
$("#shotCorn" + i)[0].weapon = $.extend({
|
||||||
@@ -542,26 +544,6 @@ Ship.prototype = {
|
|||||||
this._super("move", arguments);
|
this._super("move", arguments);
|
||||||
},
|
},
|
||||||
|
|
||||||
/* right : function(active) {
|
|
||||||
if( this.x + this.node.w() > PLAYGROUND_WIDTH ){
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
this._super("right", arguments);
|
|
||||||
|
|
||||||
this.bigWheel.rotate(this.bigWheelAngle, true);
|
|
||||||
this.smallWheel.rotate(this.smallWheelAngle, true);
|
|
||||||
},
|
|
||||||
|
|
||||||
left : function(active) {
|
|
||||||
if( this.x < 0 ){
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
this._super("left", arguments);
|
|
||||||
|
|
||||||
this.bigWheel.rotate(this.bigWheelAngle, true);
|
|
||||||
this.smallWheel.rotate(this.smallWheelAngle, true);
|
|
||||||
},
|
|
||||||
*/
|
|
||||||
up : function(active) {
|
up : function(active) {
|
||||||
if (this.y < (PLAYGROUND_HEIGHT - 2 * HUD_HEIGHT)) {
|
if (this.y < (PLAYGROUND_HEIGHT - 2 * HUD_HEIGHT)) {
|
||||||
return false;
|
return false;
|
||||||
@@ -570,19 +552,28 @@ Ship.prototype = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
destroy : function() {
|
destroy : function() {
|
||||||
|
var _this = this,
|
||||||
|
_hero = $("#hero"),
|
||||||
|
explosion = EXPLOSIONS.BIG;
|
||||||
|
|
||||||
$("#life" + this.lives).remove();
|
$("#life" + this.lives).remove();
|
||||||
this.lives = this.lives - 1;
|
this.lives = this.lives - 1;
|
||||||
$("#hero").children().hide();
|
|
||||||
if( this.lives == 0 ) {
|
|
||||||
Game.game_over();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
var _this = this;
|
$("#actors").addSprite("heroExplosion",
|
||||||
setTimeout(function() {
|
{
|
||||||
|
width: explosion[0].width,
|
||||||
|
height: explosion[0].height,
|
||||||
|
posx: _hero.x() - explosion[0].width / 2 + _hero.w(),
|
||||||
|
posy: _hero.y() - explosion[0].height / 2 - _hero.h() /4
|
||||||
|
}
|
||||||
|
);
|
||||||
|
explosionBig($("#heroExplosion"), function() {$("#heroExplosion").remove()});
|
||||||
|
_hero.children().hide();
|
||||||
|
},
|
||||||
|
|
||||||
|
respawn : function() {
|
||||||
|
$("#heroExplosion").remove();
|
||||||
$("#hero").children().show();
|
$("#hero").children().show();
|
||||||
_this.health = 1;
|
|
||||||
}, 2000);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
fire : function() {
|
fire : function() {
|
||||||
|
|||||||
Reference in New Issue
Block a user