Skip to content
Snippets Groups Projects
Commit dd168ba2 authored by Rayane Belguebli's avatar Rayane Belguebli
Browse files

add enemis LV3

parent 5d666d0b
No related branches found
No related tags found
No related merge requests found
client/public/images/boo.png

7.43 KiB

...@@ -17,6 +17,7 @@ const imageMortier = new Image(); ...@@ -17,6 +17,7 @@ const imageMortier = new Image();
const imageProjectile = new Image(); const imageProjectile = new Image();
const imageEnemi = new Image(); const imageEnemi = new Image();
const imageEnemi2 = new Image(); const imageEnemi2 = new Image();
const imageEnemi3 = new Image();
const background = new Image(); const background = new Image();
const imageCoeur = new Image(); const imageCoeur = new Image();
...@@ -24,6 +25,7 @@ imageMortier.src = '/images/mortier.png'; ...@@ -24,6 +25,7 @@ imageMortier.src = '/images/mortier.png';
imageProjectile.src = '/images/bill.png'; imageProjectile.src = '/images/bill.png';
imageEnemi.src = '/images/koopa.png'; imageEnemi.src = '/images/koopa.png';
imageEnemi2.src = '/images/bob_omb.png'; imageEnemi2.src = '/images/bob_omb.png';
imageEnemi3.src = '/images/boo.png';
background.src = '/images/background2.webp'; background.src = '/images/background2.webp';
imageCoeur.src = '/images/heart1.webp'; imageCoeur.src = '/images/heart1.webp';
let gameStarted = false; let gameStarted = false;
...@@ -210,6 +212,7 @@ function render() { ...@@ -210,6 +212,7 @@ function render() {
context, context,
imageEnemi, imageEnemi,
imageEnemi2, imageEnemi2,
imageEnemi3,
enemi.x, enemi.x,
enemi.y, enemi.y,
enemi enemi
......
...@@ -9,11 +9,22 @@ export default class Render { ...@@ -9,11 +9,22 @@ export default class Render {
} }
} }
static renderEnnemi(canvas, context, imageEnemi, imageEnemi2, x, y, enemi) { static renderEnnemi(
canvas,
context,
imageEnemi,
imageEnemi2,
imageEnemi3,
x,
y,
enemi
) {
if (enemi.difficulté == 1) { if (enemi.difficulté == 1) {
draw(canvas, context, imageEnemi, x, y); draw(canvas, context, imageEnemi, x, y);
} else if (enemi.difficulté == 2) { } else if (enemi.difficulté == 2) {
draw(canvas, context, imageEnemi2, x, y); draw(canvas, context, imageEnemi2, x, y);
} else if (enemi.difficulté) {
draw(canvas, context, imageEnemi3, x, y);
} }
} }
......
...@@ -18,6 +18,9 @@ export default class enemi extends Entite { ...@@ -18,6 +18,9 @@ export default class enemi extends Entite {
} else if (difficulté == 2) { } else if (difficulté == 2) {
this.vx = 5; this.vx = 5;
this.vy = 1; this.vy = 1;
} else if (difficulté == 3) {
this.vx = 20;
this.vy = 16;
} }
this.difficulté = difficulté; this.difficulté = difficulté;
this.vies = 2; this.vies = 2;
......
...@@ -48,6 +48,7 @@ const bonusArray = []; ...@@ -48,6 +48,7 @@ const bonusArray = [];
let cpt = 0; let cpt = 0;
let canShoot = true; let canShoot = true;
let LVL2start = false; let LVL2start = false;
let LVL3start = false;
io.on('connection', socket => { io.on('connection', socket => {
cpt++; cpt++;
...@@ -93,14 +94,10 @@ io.on('connection', socket => { ...@@ -93,14 +94,10 @@ io.on('connection', socket => {
canShoot = false; canShoot = false;
setTimeout(function () { setTimeout(function () {
canShoot = true; canShoot = true;
}, 100); }, 200);
} }
}); });
socket.on('LVL2', LVL2start => {
LVL2start = true;
});
socket.on('canvasSize', canvasSize => { socket.on('canvasSize', canvasSize => {
console.log(canvasSize); console.log(canvasSize);
canvasSize = canvasSize; canvasSize = canvasSize;
...@@ -113,6 +110,9 @@ let spawnIntervalLV1 = setInterval(() => { ...@@ -113,6 +110,9 @@ let spawnIntervalLV1 = setInterval(() => {
if (t.getMin() >= 1) { if (t.getMin() >= 1) {
LVL2start = true; LVL2start = true;
} }
if (t.getSec() >= 30) {
LVL3start = true;
}
let randomY = Math.random() * (canvasSize.height - 0) + 0; let randomY = Math.random() * (canvasSize.height - 0) + 0;
do { do {
...@@ -134,6 +134,17 @@ let spawnIntervalLV2 = setInterval(() => { ...@@ -134,6 +134,17 @@ let spawnIntervalLV2 = setInterval(() => {
} }
}, 800); }, 800);
let spawnIntervalLV3 = setInterval(() => {
if (LVL3start && gameStarted) {
let randomY = Math.random() * (canvasSize.height - 0) + 0;
do {
randomY = Math.random() * (canvasSize.height - 0) + 0;
} while (randomY > canvasSize.height - 100);
const newEnemy = new enemi(canvasSize.width - 100, randomY, 1, 3);
enemis.push(newEnemy);
}
}, 4000);
let spawnBonusInterval = setInterval(() => { let spawnBonusInterval = setInterval(() => {
if (gameStarted) { if (gameStarted) {
let randomX; let randomX;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment