Skip to content
Snippets Groups Projects
Commit 9c0458e2 authored by Mathis Decoster's avatar Mathis Decoster :apple:
Browse files

Merge branch 'main' of...

Merge branch 'main' of gitlab-ssh.univ-lille.fr:julien.bouin.etu/sae-2023-groupeh-bouin-belguebli-decoster
parents e5029a6e dd168ba2
Branches
No related tags found
No related merge requests found
client/public/images/boo.png

7.43 KiB

......@@ -21,7 +21,7 @@
<div class="divMain">
<h1>ça geek</h1>
<button class="buttonStart">Play</button>
<button class="ScoreBoard">ScoreBoard</button>
<button class="scoreBoard">ScoreBoard</button>
<button class="credits">Credits</button>
</section>
</div>
......
{
"results": [
{
"nom": "Joueur 1",
"score": 100
},
{
"nom": "Joueur 2",
"score": 200
},
{
"nom": "Joueur 3",
"score": 150
}
]
}
\ No newline at end of file
......@@ -12,11 +12,17 @@ export default class enemi extends Entite {
constructor(x, y, image, difficulté) {
super(x, y, new Hitbox(50 / 2, 66, x, y), image);
if (difficulté == 1) {
this.vx = 3;
this.vy = 0;
this.hitbox = new Hitbox(69 / 2, 57, this.x, this.y);
} else if (difficulté == 2) {
this.vx = 5;
this.vy = 1;
} else if (difficulté == 3) {
this.vx = 20;
this.vy = 16;
}
this.difficulté = difficulté;
this.vx = 3;
this.vy = 0;
this.vies = 2;
this.amplitude = 20;
this.direction = 1;
......@@ -48,14 +54,6 @@ export default class enemi extends Entite {
return this.vy;
}
setVx(vx) {
this.vx = vx;
}
setVy(vy) {
this.vy = vy;
}
deplacer() {
this.x -= this.vx;
this.hitbox.x = this.x;
......
File moved
......@@ -15,6 +15,7 @@ let canvasSize = new Coordinate(1920, 1261);
let canLostLifeAvatar = true;
let canLostLifeEnemi = true;
let gameStarted = false;
let t = new timer();
......@@ -32,8 +33,12 @@ httpServer.listen(port, () => {
});
setInterval(function () {
t.addTime();
io.emit('timer', t.getMin(), t.getSec());
if (gameStarted) {
t.addTime();
io.emit('timer', t.getMin(), t.getSec());
} else {
t = new timer();
}
}, 1000);
const avatars = [];
......@@ -43,6 +48,7 @@ const bonusArray = [];
let cpt = 0;
let canShoot = true;
let LVL2start = false;
let LVL3start = false;
io.on('connection', socket => {
cpt++;
......@@ -63,6 +69,14 @@ io.on('connection', socket => {
console.log(`Déconnexion du client ${socket.id}`);
});
socket.on('start', s => {
if (s == true && cpt != 0) {
gameStarted = s;
} else if (cpt == 0) {
gameStarted = false;
}
});
socket.on('clickEvent', clickEvent => {
const playerAvatar = avatars.find(avatar => avatar.nom === clickEvent.id);
if (playerAvatar) {
......@@ -80,14 +94,10 @@ io.on('connection', socket => {
canShoot = false;
setTimeout(function () {
canShoot = true;
}, 100);
}, 200);
}
});
socket.on('LVL2', LVL2start => {
LVL2start = true;
});
socket.on('canvasSize', canvasSize => {
console.log(canvasSize);
canvasSize = canvasSize;
......@@ -96,43 +106,59 @@ io.on('connection', socket => {
});
let spawnIntervalLV1 = setInterval(() => {
if (t.getSec() >= 10) {
LVL2start = true;
}
if (gameStarted) {
if (t.getMin() >= 1) {
LVL2start = true;
}
if (t.getSec() >= 30) {
LVL3start = true;
}
let randomY = Math.random() * (canvasSize.height - 0) + 0;
do {
randomY = Math.random() * (canvasSize.height - 0) + 0;
} while (randomY > canvasSize.height - 57);
const newEnemy = new enemi(canvasSize.width, randomY, 0, 1);
enemis.push(newEnemy);
let randomY = Math.random() * (canvasSize.height - 0) + 0;
do {
randomY = Math.random() * (canvasSize.height - 0) + 0;
} while (randomY > canvasSize.height - 57);
const newEnemy = new enemi(canvasSize.width, randomY, 0, 1);
enemis.push(newEnemy);
}
}, 1000);
let spawnIntervalLV2 = setInterval(() => {
if (LVL2start) {
if (LVL2start && 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, 2);
newEnemy.setVx(10);
newEnemy.setVy(4);
enemis.push(newEnemy);
}
}, 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 randomX;
let randomY;
const choix = Math.floor(Math.random() * bonusNoms.length);
do {
randomY = Math.random() * (canvasSize.height - 0) + 0;
} while (randomY > canvasSize.height - 75);
do {
randomX = Math.random() * (canvasSize.width - 0) + 0;
} while (randomX > canvasSize.width - 75);
const bonus = new Bonus(choix, 1, randomX, randomY, t.getTotalTime());
bonusArray.push(bonus);
if (gameStarted) {
let randomX;
let randomY;
const choix = Math.floor(Math.random() * bonusNoms.length);
do {
randomY = Math.random() * (canvasSize.height - 0) + 0;
} while (randomY > canvasSize.height - 75);
do {
randomX = Math.random() * (canvasSize.width - 0) + 0;
} while (randomX > canvasSize.width - 75);
const bonus = new Bonus(choix, 1, randomX, randomY, t.getTotalTime());
bonusArray.push(bonus);
}
}, 15000);
setInterval(() => {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment