From a192e16f7331e870a3c86c4534d359b7cd56eafc Mon Sep 17 00:00:00 2001 From: Chiara Date: Fri, 6 Dec 2019 05:47:40 +0100 Subject: [PATCH] IL NOUS A ATTRAPE --- Jeux_404/script.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Jeux_404/script.js b/Jeux_404/script.js index 6e75bc4..f6289cf 100644 --- a/Jeux_404/script.js +++ b/Jeux_404/script.js @@ -76,7 +76,7 @@ function component(largeur, longueur, color, x, y, type) { function startGame() { personnage = new component(30, 50, "blue", 10, 120); personnage.gravity = 0.05; - score = new component("30px", "Consolas", "black", 280, 40, "text"); + score = new component("30px", "Consolas", "black", 500, 40, "text"); plateau.start(); } @@ -84,6 +84,7 @@ function updateGameArea() { var x, longueur, gap, longueurMin, longueurMax, minGap, maxGap; for (i = 0; i < obstacle.length; i += 1) { if (personnage.crashWith(obstacle[i])) { + this.jeuxFini(i); return; } } @@ -116,6 +117,15 @@ function everyinterval(n) { return false; } +function jeuxFini(i) { + var messageMort; + if (personnage.crashWith(obstacle[i])) { + messageMort = new component("30px", "Consolas", "red", 150, 60, "text"); + messageMort.text = "Il vous à attrapé..."; + messageMort.update(); + } +} + function sauter(n) { personnage.gravity = n; }