Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
ff6e4f1188
@ -1,21 +1,38 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
|
<!--https:/www.w3schools.com/graphics/game_intro.asp-->
|
||||||
|
<!--https:/www.trex-game.skipser.com-->
|
||||||
|
|
||||||
<html>
|
<html>
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
|
<meta charset="UTF8" />
|
||||||
<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: 1px solid #d3d3d3;
|
||||||
background-color: #f1f1f1;
|
background-color: #f1f1f1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.center {
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
button {
|
||||||
|
margin-top: +300px;
|
||||||
|
display: block;
|
||||||
|
margin-left: auto;
|
||||||
|
margin-right: auto;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body onload="startGame()">
|
<body onload="startGame()" onload="load()">
|
||||||
|
<h1 class="center">Fuyez l'homme en noir !</h1>
|
||||||
|
<script src="./scores.js"></script>
|
||||||
<script src="./script.js"></script>
|
<script src="./script.js"></script>
|
||||||
|
|
||||||
<br>
|
<br>
|
||||||
<button onmousedown="sauter(-0.5)" onmouseup="sauter(0.05)">SAUTER</button>
|
<button onmousedown="sauter(-0.5)" onmouseup="sauter(0.05)">SAUTER</button>
|
||||||
<p>Fuyez l'homme en noir !</p>
|
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
@ -1,20 +1,15 @@
|
|||||||
|
//VARIABLES
|
||||||
var personnage;
|
var personnage;
|
||||||
var obstacle = [];
|
var obstacle = [];
|
||||||
var score;
|
var score;
|
||||||
|
|
||||||
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();
|
|
||||||
}
|
|
||||||
|
|
||||||
var plateau = {
|
var plateau = {
|
||||||
canvas: document.createElement("canvas"),
|
canvas: document.createElement("canvas"),
|
||||||
start: function() {
|
start: function() {
|
||||||
this.canvas.width = 480;
|
this.canvas.width = 480;
|
||||||
this.canvas.height = 270;
|
this.canvas.height = 270;
|
||||||
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";
|
||||||
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);
|
||||||
@ -24,6 +19,7 @@ var plateau = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//CONSTRUCTEURS
|
||||||
function component(largeur, longueur, color, x, y, type) {
|
function component(largeur, longueur, color, x, y, type) {
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.score = 0;
|
this.score = 0;
|
||||||
@ -76,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() {
|
function updateGameArea() {
|
||||||
var x, taille, gap, tailleMin, tailleMax, minGap, maxGap;
|
var x, taille, gap, tailleMin, tailleMax, minGap, maxGap;
|
||||||
for (i = 0; i < obstacle.length; i += 1) {
|
for (i = 0; i < obstacle.length; i += 1) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user