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
+120 -2
View File
@@ -27,6 +27,7 @@ MyGame = ig.Game.extend({
gravity: 200,
player: null,
boss: null,
score: 0,
checkpoint: null,
@@ -38,6 +39,9 @@ MyGame = ig.Game.extend({
ig.input.bind(ig.KEY.LEFT_ARROW, 'left');
ig.input.bind(ig.KEY.UP_ARROW, 'up');
ig.input.bind(ig.KEY.SPACE, 'space');
this.timer = new ig.Timer(5);
this.cheesetimer = new ig.Timer(15);
},
@@ -46,10 +50,10 @@ MyGame = ig.Game.extend({
this.parent();
this.player = this.getEntitiesByType(EntityKuroneko)[0];
this.boss = this.getEntitiesByType(EntityFinalboss)[0];
if (this.player) {
this.scrollScreen();
}
}
if (this.currentLevel == LevelTitle) {
//play title music
@@ -81,6 +85,19 @@ MyGame = ig.Game.extend({
this.loadLevel( LevelTitle );
}
}
var randomX = Math.floor(Math.random() * (5824 - 5184 + 1) ) + 5184;
if (this.timer.delta() > 5 && this.boss && this.player.pos.x > 5056) {
this.spawnEntity(EntityMouse, randomX, 448);
this.timer.reset();
}
if (this.cheesetimer.delta() > 15 && this.boss && this.player.pos.x > 5056) {
this.spawnEntity(EntityCheese, randomX, 586);
console.log(this.cheesetimer.delta());
this.cheesetimer.reset();
}
},
loadLevel: function(data) {
@@ -123,6 +140,7 @@ MyGame = ig.Game.extend({
this.parent();
this.player = this.getEntitiesByType(EntityKuroneko)[0];
this.boss = this.getEntitiesByType(EntityFinalboss)[0];
var canvas = document.getElementById('canvas');
var ctx = canvas.getContext('2d');
@@ -177,6 +195,106 @@ MyGame = ig.Game.extend({
ctx.stroke();
ctx.fillStyle = '#ac3232';
ctx.fillRect(63, 33, 0, 10);
if (this.player.pos.x > 5056 && this.boss) {
if (this.boss.health == 10) {
ctx.beginPath();
ctx.lineWidth = '10';
ctx.strokeStyle = '#808080';
ctx.rect(230, 100, 500, 30);
ctx.stroke();
ctx.fillStyle = "#3c813f";
ctx.fillRect(235, 105, 490, 20);
}
if (this.boss.health == 9) {
ctx.beginPath();
ctx.lineWidth = '10';
ctx.strokeStyle = '#808080';
ctx.rect(230, 100, 500, 30);
ctx.stroke();
ctx.fillStyle = "#3c813f";
ctx.fillRect(235, 105, 441, 20);
}
if (this.boss.health == 8) {
ctx.beginPath();
ctx.lineWidth = '10';
ctx.strokeStyle = '#808080';
ctx.rect(230, 100, 500, 30);
ctx.stroke();
ctx.fillStyle = "#3c813f";
ctx.fillRect(235, 105, 392, 20);
}
if (this.boss.health == 7) {
ctx.beginPath();
ctx.lineWidth = '10';
ctx.strokeStyle = '#808080';
ctx.rect(230, 100, 500, 30);
ctx.stroke();
ctx.fillStyle = "#3c813f";
ctx.fillRect(235, 105, 343, 20);
}
if (this.boss.health == 6) {
ctx.beginPath();
ctx.lineWidth = '10';
ctx.strokeStyle = '#808080';
ctx.rect(230, 100, 500, 30);
ctx.stroke();
ctx.fillStyle = "#3c813f";
ctx.fillRect(235, 105, 294, 20);
}
if (this.boss.health == 5) {
ctx.beginPath();
ctx.lineWidth = '10';
ctx.strokeStyle = '#808080';
ctx.rect(230, 100, 500, 30);
ctx.stroke();
ctx.fillStyle = "#3c813f";
ctx.fillRect(235, 105, 245, 20);
}
if (this.boss.health == 4) {
ctx.beginPath();
ctx.lineWidth = '10';
ctx.strokeStyle = '#808080';
ctx.rect(230, 100, 500, 30);
ctx.stroke();
ctx.fillStyle = "#3c813f";
ctx.fillRect(235, 105, 196, 20);
}
if (this.boss.health == 3) {
ctx.beginPath();
ctx.lineWidth = '10';
ctx.strokeStyle = '#808080';
ctx.rect(230, 100, 500, 30);
ctx.stroke();
ctx.fillStyle = "#3c813f";
ctx.fillRect(235, 105, 147, 20);
}
if (this.boss.health == 2) {
ctx.beginPath();
ctx.lineWidth = '10';
ctx.strokeStyle = '#808080';
ctx.rect(230, 100, 500, 30);
ctx.stroke();
ctx.fillStyle = "#3c813f";
ctx.fillRect(235, 105, 98, 20);
}
if (this.boss.health == 1) {
ctx.beginPath();
ctx.lineWidth = '10';
ctx.strokeStyle = '#808080';
ctx.rect(230, 100, 500, 30);
ctx.stroke();
ctx.fillStyle = "#3c813f";
ctx.fillRect(235, 105, 49, 20);
}
if (this.boss.health == 0) {
ctx.beginPath();
ctx.lineWidth = '10';
ctx.strokeStyle = '#808080';
ctx.rect(230, 100, 500, 30);
ctx.stroke();
}
}
}
}
});