Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
975df5f68f
BIN
Jeux_404/gifs/homme trop swag.gif
Normal file
BIN
Jeux_404/gifs/homme trop swag.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 146 B |
@ -9,8 +9,7 @@
|
|||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
<style>
|
<style>
|
||||||
canvas {
|
canvas {
|
||||||
border: 1px solid #d3d3d3;
|
border-bottom: 2px solid #0d0d0d;
|
||||||
background-color: #f1f1f1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.center {
|
.center {
|
||||||
@ -18,21 +17,38 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
button {
|
button {
|
||||||
margin-top: +300px;
|
margin-top: +50px;
|
||||||
display: block;
|
display: block;
|
||||||
margin-left: auto;
|
margin-left: auto;
|
||||||
margin-right: auto;
|
margin-right: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
img {
|
||||||
|
margin-top: +130px;
|
||||||
|
margin-left: +300px;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body onload="startGame()" onload="load()">
|
<body>
|
||||||
<h1 class="center">Fuyez l'homme en noir !</h1>
|
<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>
|
<br>
|
||||||
<button onmousedown="sauter(-0.5)" onmouseup="sauter(0.05)">SAUTER</button>
|
<button onmousedown="sauter(-0.5)" onmouseup="sauter(0.05)">SAUTER</button>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
startGame()
|
||||||
|
load()
|
||||||
|
</script>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
43
Jeux_404/scores.js
Normal file
43
Jeux_404/scores.js
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
//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++)
|
||||||
|
tableau.start();
|
||||||
|
}
|
@ -6,10 +6,10 @@ var score;
|
|||||||
var plateau = {
|
var plateau = {
|
||||||
canvas: document.createElement("canvas"),
|
canvas: document.createElement("canvas"),
|
||||||
start: function() {
|
start: function() {
|
||||||
this.canvas.width = 480;
|
this.canvas.width = 700;
|
||||||
this.canvas.height = 270;
|
this.canvas.height = 280;
|
||||||
this.context = this.canvas.getContext("2d");
|
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]);
|
document.body.insertBefore(this.canvas, document.body.childNodes[0]);
|
||||||
this.frameNo = 0;
|
this.frameNo = 0;
|
||||||
this.interval = setInterval(updateGameArea, 20);
|
this.interval = setInterval(updateGameArea, 20);
|
||||||
@ -83,7 +83,7 @@ function startGame() {
|
|||||||
|
|
||||||
|
|
||||||
function updateGameArea() {
|
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) {
|
for (i = 0; i < obstacle.length; i += 1) {
|
||||||
if (personnage.crashWith(obstacle[i])) {
|
if (personnage.crashWith(obstacle[i])) {
|
||||||
return;
|
return;
|
||||||
@ -93,14 +93,13 @@ function updateGameArea() {
|
|||||||
plateau.frameNo += 1;
|
plateau.frameNo += 1;
|
||||||
if (plateau.frameNo == 1 || everyinterval(150)) {
|
if (plateau.frameNo == 1 || everyinterval(150)) {
|
||||||
x = plateau.canvas.width;
|
x = plateau.canvas.width;
|
||||||
tailleMin = 20;
|
longueurMin = 20;
|
||||||
tailleMax = 200;
|
longueurMax = 200;
|
||||||
taille = Math.floor(Math.random() * (tailleMax - tailleMin + 1) + tailleMin);
|
longueur = Math.floor(Math.random() * (longueurMax - longueurMin + 1) + longueurMin);
|
||||||
minGap = 50;
|
minGap = 50;
|
||||||
maxGap = 200;
|
maxGap = 200;
|
||||||
gap = Math.floor(Math.random() * (maxGap - minGap + 1) + minGap);
|
gap = Math.floor(Math.random() * (maxGap - minGap + 1) + minGap);
|
||||||
obstacle.push(new component(10, taille, "green", x, 0));
|
obstacle.push(new component(10, x - longueur - gap, "grey", x, longueur + gap));
|
||||||
obstacle.push(new component(10, x - taille - gap, "green", x, taille + gap));
|
|
||||||
}
|
}
|
||||||
for (i = 0; i < obstacle.length; i += 1) {
|
for (i = 0; i < obstacle.length; i += 1) {
|
||||||
obstacle[i].x += -1;
|
obstacle[i].x += -1;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user