From f0f8da4a2d4220daa32983c95d7cf032deedec48 Mon Sep 17 00:00:00 2001 From: Chiara Date: Thu, 5 Dec 2019 23:49:19 +0100 Subject: [PATCH] sauvegarde avant tentative --- Jeux_404/main.html | 16 ++++++++++++++-- Jeux_404/scores.js | 44 ++++++++++++++++++++++++++++++++++++++++++++ Jeux_404/script.js | 21 ++++++++++++--------- 3 files changed, 70 insertions(+), 11 deletions(-) create mode 100644 Jeux_404/scores.js diff --git a/Jeux_404/main.html b/Jeux_404/main.html index a208f33..6005a28 100644 --- a/Jeux_404/main.html +++ b/Jeux_404/main.html @@ -1,7 +1,11 @@ + + + + - +

Fuyez l'homme en noir !

+
- + \ No newline at end of file diff --git a/Jeux_404/scores.js b/Jeux_404/scores.js new file mode 100644 index 0000000..ae4d744 --- /dev/null +++ b/Jeux_404/scores.js @@ -0,0 +1,44 @@ +//VARIABLES +var premier = 0; +var deuxieme = 0; +var troisième = 0; + +var ligne; + +var score = new Array("1ST", "2ND", "3RD"); +var premier = score["1ST"]; +var deuxieme = score["2ND"]; +var troisième = score["3RD"]; + +var tableau = { + canvas: document.createElement("canvas"), + start: function() { + this.canvas.width = 200; + this.canvas.height = 150; + this.context = this.canvas.getContext("2d"); + document.body.insertBefore(this.canvas, document.body.childNodes[0]); + this.frameNo = 0; + this.interval = setInterval(updateGameArea, 20); + }, + clear: function() { + this.context.clearRect(0, 0, this.canvas.width, this.canvas.height); + } +} + +//METHODES +function update(score) { + if (score > premier) + this.premier = score; + else if (score > deuxieme) + this.deuxieme = score; + else if (score > troisième) + this.troisième = score; +} + +function load() { + alert("passe"); + update(); + for (var i = 0; i < score.lenght; i++) + document.write(score[i] + score[score[i]] + < br / > ); + tableau.start(); +} \ No newline at end of file diff --git a/Jeux_404/script.js b/Jeux_404/script.js index 2c1d8d3..dcce74c 100644 --- a/Jeux_404/script.js +++ b/Jeux_404/script.js @@ -9,7 +9,7 @@ var plateau = { this.canvas.width = 480; this.canvas.height = 270; this.context = this.canvas.getContext("2d"); - this.canvas.style = "position:absolute; left: 50%; width: 400px; margin-left: -200px;"; + this.canvas.style = "position:absolute; left: 50%; margin-left: -250px; bottom: 50%; margin-bottom: +50px"; document.body.insertBefore(this.canvas, document.body.childNodes[0]); this.frameNo = 0; this.interval = setInterval(updateGameArea, 20); @@ -19,14 +19,7 @@ var plateau = { } } -//METHODES -function startGame() { - personnage = new component(30, 30, "red", 10, 120); - personnage.gravity = 0.05; - score = new component("30px", "Consolas", "black", 280, 40, "text"); - plateau.start(); -} - +//CONSTRUCTEURS function component(largeur, longueur, color, x, y, type) { this.type = type; this.score = 0; @@ -79,6 +72,16 @@ function component(largeur, longueur, color, x, y, type) { } } +//METHODES +function startGame() { + personnage = new component(30, 30, "blue", 10, 120); + personnage.gravity = 0.05; + score = new component("30px", "Consolas", "black", 280, 40, "text"); + plateau.start(); +} + + + function updateGameArea() { var x, taille, gap, tailleMin, tailleMax, minGap, maxGap; for (i = 0; i < obstacle.length; i += 1) {