mirror of
https://github.com/Febbweiss/sis.git
synced 2026-03-04 22:25:35 +00:00
Feature: adding explosions
Feature: adding CornWeapon explosion animation
This commit is contained in:
BIN
images/explosion_big.png
Normal file
BIN
images/explosion_big.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 360 KiB |
BIN
images/explosion_small.png
Normal file
BIN
images/explosion_small.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 20 KiB |
@@ -10,8 +10,124 @@
|
|||||||
|
|
||||||
var ALIENS_WIDTH = 24,
|
var ALIENS_WIDTH = 24,
|
||||||
ALIENS_HEIGHT = 17,
|
ALIENS_HEIGHT = 17,
|
||||||
IMAGES_PREFIX = "images/";
|
IMAGES_PREFIX = "images/",
|
||||||
|
EXPLOSION_BIG = IMAGES_PREFIX + "explosion_big.png",
|
||||||
|
EXPLOSION_BIG_RATE = 50,
|
||||||
|
EXPLOSION_SMALL = IMAGES_PREFIX + "explosion_small.png",
|
||||||
|
EXPLOSION_SMALL_RATE = 50;
|
||||||
|
|
||||||
|
var EXPLOSIONS = {
|
||||||
|
BIG : [
|
||||||
|
{
|
||||||
|
animation : new $.gQ.Animation({
|
||||||
|
imageURL : EXPLOSION_BIG,
|
||||||
|
numberOfFrame : 8,
|
||||||
|
delta : 128,
|
||||||
|
rate : EXPLOSION_BIG_RATE,
|
||||||
|
type : $.gQ.ANIMATION_HORIZONTAL | $.gQ.ANIMATION_CALLBACK
|
||||||
|
}),
|
||||||
|
width : 128,
|
||||||
|
height: 128
|
||||||
|
},
|
||||||
|
{
|
||||||
|
animation : new $.gQ.Animation({
|
||||||
|
imageURL : EXPLOSION_BIG,
|
||||||
|
offsety : 128,
|
||||||
|
numberOfFrame : 8,
|
||||||
|
delta : 128,
|
||||||
|
rate : EXPLOSION_BIG_RATE,
|
||||||
|
type : $.gQ.ANIMATION_HORIZONTAL | $.gQ.ANIMATION_CALLBACK
|
||||||
|
}),
|
||||||
|
width : 128,
|
||||||
|
height: 128
|
||||||
|
},
|
||||||
|
{
|
||||||
|
animation : new $.gQ.Animation({
|
||||||
|
imageURL : EXPLOSION_BIG,
|
||||||
|
offsety : 256,
|
||||||
|
numberOfFrame : 8,
|
||||||
|
delta : 128,
|
||||||
|
rate : EXPLOSION_BIG_RATE,
|
||||||
|
type : $.gQ.ANIMATION_HORIZONTAL | $.gQ.ANIMATION_CALLBACK
|
||||||
|
}),
|
||||||
|
width : 128,
|
||||||
|
height: 128
|
||||||
|
},
|
||||||
|
{
|
||||||
|
animation : new $.gQ.Animation({
|
||||||
|
imageURL : EXPLOSION_BIG,
|
||||||
|
offsety : 384,
|
||||||
|
numberOfFrame : 8,
|
||||||
|
delta : 128,
|
||||||
|
rate : EXPLOSION_BIG_RATE,
|
||||||
|
type : $.gQ.ANIMATION_HORIZONTAL | $.gQ.ANIMATION_CALLBACK
|
||||||
|
}),
|
||||||
|
width : 128,
|
||||||
|
height: 128
|
||||||
|
},
|
||||||
|
{
|
||||||
|
animation : new $.gQ.Animation({
|
||||||
|
imageURL : EXPLOSION_BIG,
|
||||||
|
offsety : 512,
|
||||||
|
numberOfFrame : 8,
|
||||||
|
delta : 128,
|
||||||
|
rate : EXPLOSION_BIG_RATE,
|
||||||
|
type : $.gQ.ANIMATION_HORIZONTAL | $.gQ.ANIMATION_CALLBACK
|
||||||
|
}),
|
||||||
|
width : 128,
|
||||||
|
height: 128
|
||||||
|
},
|
||||||
|
{
|
||||||
|
animation : new $.gQ.Animation({
|
||||||
|
imageURL : EXPLOSION_BIG,
|
||||||
|
offsety : 640,
|
||||||
|
numberOfFrame : 8,
|
||||||
|
delta : 128,
|
||||||
|
rate : EXPLOSION_BIG_RATE,
|
||||||
|
type : $.gQ.ANIMATION_HORIZONTAL | $.gQ.ANIMATION_CALLBACK
|
||||||
|
}),
|
||||||
|
width : 128,
|
||||||
|
height: 128
|
||||||
|
},
|
||||||
|
{
|
||||||
|
animation : new $.gQ.Animation({
|
||||||
|
imageURL : EXPLOSION_BIG,
|
||||||
|
offsety : 768,
|
||||||
|
numberOfFrame : 8,
|
||||||
|
delta : 128,
|
||||||
|
rate : EXPLOSION_BIG_RATE,
|
||||||
|
type : $.gQ.ANIMATION_HORIZONTAL | $.gQ.ANIMATION_CALLBACK | $.gQ.ANIMATION_ONCE
|
||||||
|
}),
|
||||||
|
width : 128,
|
||||||
|
height: 128
|
||||||
|
},
|
||||||
|
{
|
||||||
|
animation : new $.gQ.Animation({
|
||||||
|
imageURL : EXPLOSION_BIG,
|
||||||
|
offsety : 896,
|
||||||
|
numberOfFrame : 8,
|
||||||
|
delta : 128,
|
||||||
|
rate : EXPLOSION_BIG_RATE,
|
||||||
|
type : $.gQ.ANIMATION_HORIZONTAL | $.gQ.ANIMATION_CALLBACK | $.gQ.ANIMATION_ONCE
|
||||||
|
}),
|
||||||
|
width : 128,
|
||||||
|
height: 128
|
||||||
|
}
|
||||||
|
],
|
||||||
|
SMALL : [
|
||||||
|
{
|
||||||
|
animation : new $.gQ.Animation({
|
||||||
|
imageURL : EXPLOSION_SMALL,
|
||||||
|
numberOfFrame : 10,
|
||||||
|
delta : 64,
|
||||||
|
rate : EXPLOSION_SMALL_RATE,
|
||||||
|
type : $.gQ.ANIMATION_HORIZONTAL | $.gQ.ANIMATION_CALLBACK | $.gQ.ANIMATION_ONCE
|
||||||
|
}),
|
||||||
|
width : 64,
|
||||||
|
height: 64
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
var WORLD = {
|
var WORLD = {
|
||||||
farm : {
|
farm : {
|
||||||
hero : {
|
hero : {
|
||||||
|
|||||||
@@ -186,7 +186,7 @@ Game = {
|
|||||||
Game.game_over();
|
Game.game_over();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if( alien.health > 0 && Math.random() < alien.aggression ) {
|
if( alien.health > 0 && Math.random() < (alien.aggression * (Game.wave_index + 1)) ) {
|
||||||
alien.fire($("#aliensShots"), "alienShot");
|
alien.fire($("#aliensShots"), "alienShot");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -299,7 +299,11 @@ function CornWeapon() {
|
|||||||
var mediumAlien = getAliensMidHeight();
|
var mediumAlien = getAliensMidHeight();
|
||||||
|
|
||||||
if( shot.y() < mediumAlien ) {
|
if( shot.y() < mediumAlien ) {
|
||||||
|
var explosion = EXPLOSIONS.SMALL[0];
|
||||||
|
$("#shipShots").addSprite("cornExplosion", {width: explosion.width, height: explosion.height, posx: shot.x() - explosion.width / 2, posy: shot.y() - explosion.height / 2});
|
||||||
|
explosionSmall($("#cornExplosion"), function() {$("#cornExplosion").remove()});
|
||||||
shot.remove();
|
shot.remove();
|
||||||
|
|
||||||
var shipShots = $("#shipShots");
|
var shipShots = $("#shipShots");
|
||||||
for( var i = 0; i < 8; i++) {
|
for( var i = 0; i < 8; i++) {
|
||||||
var cos = Math.cos( (Math.PI / 4) * i ),
|
var cos = Math.cos( (Math.PI / 4) * i ),
|
||||||
|
|||||||
@@ -26,6 +26,25 @@ var PLAYGROUND_WIDTH = 448,
|
|||||||
|
|
||||||
var animations = WORLD.farm;
|
var animations = WORLD.farm;
|
||||||
|
|
||||||
|
|
||||||
|
function explose( div, explosion, step, callback ) {
|
||||||
|
if( step < explosion.length - 2 ) {
|
||||||
|
div.setAnimation( explosion[step].animation, function() {
|
||||||
|
explose( div, explosion, step + 1, callback );
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
div.setAnimation( explosion[step].animation, callback);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
function explosionBig( div, callback ) {
|
||||||
|
explose(div, EXPLOSIONS.BIG, 0, callback );
|
||||||
|
};
|
||||||
|
|
||||||
|
function explosionSmall( div, callback ) {
|
||||||
|
explose(div, EXPLOSIONS.SMALL, 0, callback );
|
||||||
|
};
|
||||||
|
|
||||||
function displayModal(data) {
|
function displayModal(data) {
|
||||||
var score = data.score.toString();
|
var score = data.score.toString();
|
||||||
$.playground()
|
$.playground()
|
||||||
@@ -107,6 +126,12 @@ $(function(){
|
|||||||
posy: PLAYGROUND_HEIGHT - HUD_HEIGHT - 50
|
posy: PLAYGROUND_HEIGHT - HUD_HEIGHT - 50
|
||||||
})
|
})
|
||||||
.end()
|
.end()
|
||||||
|
.addSprite("explosion", {
|
||||||
|
width: 64,
|
||||||
|
height: 64,
|
||||||
|
posx: 100,
|
||||||
|
posy: 100
|
||||||
|
})
|
||||||
.end()
|
.end()
|
||||||
.addGroup( "shipShots", {posx: 0, posy: HUD_HEIGHT, width: PLAYGROUND_WIDTH, height: PLAYGROUND_HEIGHT - HUD_HEIGHT})
|
.addGroup( "shipShots", {posx: 0, posy: HUD_HEIGHT, width: PLAYGROUND_WIDTH, height: PLAYGROUND_HEIGHT - HUD_HEIGHT})
|
||||||
.end()
|
.end()
|
||||||
|
|||||||
Reference in New Issue
Block a user