Final touches before music and sound effects

This commit is contained in:
IllusionMan1212
2018-09-30 16:39:00 +02:00
parent 13e35a0a7b
commit c73fb1e274
5 changed files with 285 additions and 75 deletions
+86
View File
@@ -0,0 +1,86 @@
ig.module(
'game.entities.finalboss'
)
.requires(
'impact.entity',
'game.entities.kuroneko',
)
.defines(function() {
EntityFinalboss = ig.Entity.extend({
collides: ig.Entity.COLLIDES.PASSIVE,
size: {x: 78, y: 27},
gravityFactor: 4,
speed: 400,
health: 10,
maxVel: {x: 300, y: 100},
flip: false,
player: null,
is_dead: false,
animSheet: new ig.AnimationSheet('media/finalboss.png', 78, 27),
init: function(x, y, settings) {
this.parent(x, y, settings);
this.addAnim('normal', 1, [0]);
this.addAnim('dead', 1, [1]);
},
update: function() {
this.parent();
if (!this.is_dead) {
this.currentAnim = this.anims.normal;
} else {
this.currentAnim = this.anims.dead;
this.currentAnim.flip.y = true;
}
this.currentAnim.flip.x = this.flip;
this.vel.x = this.speed * this.turnAround();
},
handleMovementTrace: function(res) {
this.parent(res);
if (res.collision.x) {
this.flip = !this.flip;
}
},
collideWith: function(other, axis) {
this.player = ig.game.getEntitiesByType(EntityKuroneko)[0];
if (other instanceof EntityKuroneko) {
if (axis === 'y') {
this.receiveDamage(1, this.player);
this.player.vel.y = -400;
} else if (axis === 'x') {
this.player.receiveDamage(2, this);
if (this.player.pos.x < this.pos.x) {
this.player.vel.x = -500;
} else {
this.player.vel.x = 500;
}
}
}
},
turnAround: function() {
var x = this.pos.x + (this.flip ? + 5 : this.size.x - 5);
var y = this.pos.y + this.size.y + 5;
if(!ig.game.collisionMap.getTile(x, y)){
this.flip = !this.flip;
}
return this.flip ? -1 : 1;
},
kill: function() {
this.is_dead = true;
this.speed = 0;
ig.game.score += 1000;
this.collides = ig.Entity.COLLIDES.NEVER;
setTimeout(function(){ig.game.removeEntity(this);}.bind(this), 500);
}
})
})
+8 -7
View File
@@ -11,7 +11,7 @@ ig.module(
collides: ig.Entity.COLLIDES.PASSIVE,
size: {x: 26, y: 9},
gravityFactor: 4,
gravityFactor: 10,
speed: 100,
maxVel: {x: 300, y: 100},
flip: true,
@@ -36,10 +36,9 @@ ig.module(
this.currentAnim = this.anims.dead;
this.currentAnim.flip.y = true;
}
this.currentAnim.flip.x = this.flip;
var xdir = this.flip ? -1:1;
this.vel.x = this.speed * this.turnAround();;
this.currentAnim.flip.x = this.flip;
this.vel.x = this.speed * this.turnAround();
},
handleMovementTrace: function(res) {
@@ -53,10 +52,12 @@ ig.module(
collideWith: function(other, axis) {
this.player = ig.game.getEntitiesByType(EntityKuroneko)[0];
if (other instanceof EntityKuroneko) {
if (axis === 'y') {
if (axis === 'y' && this.player.pos.y < this.pos.y) {
this.kill();
this.player.vel.y = -200;
this.player.vel.y = -300;
ig.game.score += 100;
} else if (axis === 'y' && this.player.pos.y > this.pos.y) {
this.player.receiveDamage(1, this);
} else if (axis === 'x') {
this.player.receiveDamage(1, this);
if (this.player.pos.x < this.pos.x) {
@@ -75,7 +76,7 @@ ig.module(
if(!ig.game.collisionMap.getTile(x, y)){
this.flip = !this.flip;
}
return this.flip ? -1 : 1;
return this.flip ? -1 : 1;
},
kill: function() {