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

correctif + refacto

parent 8c75eec7
No related branches found
No related tags found
No related merge requests found
...@@ -42,8 +42,7 @@ document ...@@ -42,8 +42,7 @@ document
.addEventListener('click', affichage.afficherCredits); .addEventListener('click', affichage.afficherCredits);
function startGame(event) { function startGame(event) {
gameStarted = true; const canvasSize = affichage.startGame(event, canvas);
const canvasSize = affichage.startGame(event, socket, canvas);
socket.emit('canvasSize', canvasSize); socket.emit('canvasSize', canvasSize);
} }
......
...@@ -40,7 +40,7 @@ export default class Render { ...@@ -40,7 +40,7 @@ export default class Render {
} else if (enemi.difficulté == 2) { } else if (enemi.difficulté == 2) {
draw(canvas, context, this.imageEnemi2, x, y); draw(canvas, context, this.imageEnemi2, x, y);
} else if (enemi.difficulté == 3) { } else if (enemi.difficulté == 3) {
draw(canvas, context, imageEnemi3, x, y); draw(canvas, context, this.imageEnemi3, x, y);
} }
} }
......
...@@ -126,10 +126,7 @@ let spawnIntervalLV1 = setInterval(() => { ...@@ -126,10 +126,7 @@ let spawnIntervalLV1 = setInterval(() => {
let spawnIntervalLV2 = setInterval(() => { let spawnIntervalLV2 = setInterval(() => {
if (LVL2start && gameStarted) { if (LVL2start && gameStarted) {
let randomY = Math.random() * (canvasSize.height - 0) + 0; let randomY = Math.random() * (canvasSize.height - 100);
do {
randomY = Math.random() * (canvasSize.height - 0) + 0;
} while (randomY > canvasSize.height - 100);
const newEnemy = new enemi(canvasSize.width - 100, randomY, 1, 2); const newEnemy = new enemi(canvasSize.width - 100, randomY, 1, 2);
enemis.push(newEnemy); enemis.push(newEnemy);
} }
...@@ -137,10 +134,7 @@ let spawnIntervalLV2 = setInterval(() => { ...@@ -137,10 +134,7 @@ let spawnIntervalLV2 = setInterval(() => {
let spawnIntervalLV3 = setInterval(() => { let spawnIntervalLV3 = setInterval(() => {
if (LVL3start && gameStarted) { if (LVL3start && gameStarted) {
let randomY = Math.random() * (canvasSize.height - 0) + 0; let randomY = Math.random() * (canvasSize.height - 100);
do {
randomY = Math.random() * (canvasSize.height - 0) + 0;
} while (randomY > canvasSize.height - 100);
const newEnemy = new enemi(canvasSize.width - 100, randomY, 1, 3); const newEnemy = new enemi(canvasSize.width - 100, randomY, 1, 3);
enemis.push(newEnemy); enemis.push(newEnemy);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment