sauvegarde avant scores

This commit is contained in:
Chiara 2019-12-06 01:43:54 +01:00
parent 100e22c0e5
commit 01a5e11b69
4 changed files with 74 additions and 15 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 146 B

View File

@ -9,8 +9,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<style>
canvas {
border: 1px solid #d3d3d3;
background-color: #f1f1f1;
border-bottom: 2px solid #0d0d0d;
}
.center {
@ -18,21 +17,38 @@
}
button {
margin-top: +300px;
margin-top: +50px;
display: block;
margin-left: auto;
margin-right: auto;
}
img {
margin-top: +130px;
margin-left: +300px;
}
</style>
</head>
<body onload="startGame()" onload="load()">
<body>
<h1 class="center">Fuyez l'homme en noir !</h1>
<script src="./scores.js"></script>
<script src="./script.js"></script>
<script src="./scores.js">
startGame()
</script>
<script src="./script.js">
load()
</script>
<img src="./gifs/homme trop swag.gif" alt="homme en noir" height="150" width="150">
<br>
<button onmousedown="sauter(-0.5)" onmouseup="sauter(0.05)">SAUTER</button>
<script>
startGame()
load()
</script>
</body>
</html>

44
Jeux_404/scores.js Normal file
View File

@ -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");
this.canvas.style = "position:absolute; margin-write: +500px; border: 2px solid #0d0d0d;";
document.body.insertBefore(this.canvas, document.body.childNodes[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() {
update();
for (var i = 0; i < score.lenght; i++)
document.write("j'écris");
//document.write(score[i] + score[score[i]] + '<br />');
tableau.start();
}

View File

@ -6,10 +6,10 @@ var score;
var plateau = {
canvas: document.createElement("canvas"),
start: function() {
this.canvas.width = 480;
this.canvas.height = 270;
this.canvas.width = 700;
this.canvas.height = 280;
this.context = this.canvas.getContext("2d");
this.canvas.style = "position:absolute; left: 50%; margin-left: -250px; bottom: 50%; margin-bottom: +50px";
this.canvas.style = "position:absolute; left: 50%; margin-left: -250px; bottom: 50%; margin-top: +50px";
document.body.insertBefore(this.canvas, document.body.childNodes[0]);
this.frameNo = 0;
this.interval = setInterval(updateGameArea, 20);
@ -83,7 +83,7 @@ function startGame() {
function updateGameArea() {
var x, taille, gap, tailleMin, tailleMax, minGap, maxGap;
var x, longueur, gap, longueurMin, longueurMax, minGap, maxGap;
for (i = 0; i < obstacle.length; i += 1) {
if (personnage.crashWith(obstacle[i])) {
return;
@ -93,14 +93,13 @@ function updateGameArea() {
plateau.frameNo += 1;
if (plateau.frameNo == 1 || everyinterval(150)) {
x = plateau.canvas.width;
tailleMin = 20;
tailleMax = 200;
taille = Math.floor(Math.random() * (tailleMax - tailleMin + 1) + tailleMin);
longueurMin = 20;
longueurMax = 200;
longueur = Math.floor(Math.random() * (longueurMax - longueurMin + 1) + longueurMin);
minGap = 50;
maxGap = 200;
gap = Math.floor(Math.random() * (maxGap - minGap + 1) + minGap);
obstacle.push(new component(10, taille, "green", x, 0));
obstacle.push(new component(10, x - taille - gap, "green", x, taille + gap));
obstacle.push(new component(10, x - longueur - gap, "grey", x, longueur + gap));
}
for (i = 0; i < obstacle.length; i += 1) {
obstacle[i].x += -1;