Update index.php
This commit is contained in:
63
index.php
63
index.php
@@ -1,62 +1,15 @@
|
|||||||
<?php
|
<?php
|
||||||
// later kan hier PHP score / sessions
|
echo "hellotjes"
|
||||||
|
?>
|
||||||
|
echo "yo ";
|
||||||
?>
|
?>
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="nl">
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<title>PHP test</title>
|
||||||
<title>loading...</title>
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
<h1>dit komt uit html</h1>
|
||||||
<h1>Kijk naar de tab 👆</h1>
|
<p><?php echo "dit komt uit PHP"; ?></p>
|
||||||
|
|
||||||
<script>
|
|
||||||
// vaste dino positie
|
|
||||||
const dinoPos = 5;
|
|
||||||
|
|
||||||
// wereld (komma = obstakel)
|
|
||||||
let world = " , , , ";
|
|
||||||
let jumping = false;
|
|
||||||
let jumpFrames = 0;
|
|
||||||
|
|
||||||
function gameTick() {
|
|
||||||
// wereld schuift naar links
|
|
||||||
world = world.slice(1) + (Math.random() < 0.15 ? "," : " ");
|
|
||||||
|
|
||||||
let display = "";
|
|
||||||
for (let i = 0; i < world.length; i++) {
|
|
||||||
if (i === dinoPos) {
|
|
||||||
// dino
|
|
||||||
if (jumping && world[i] === ",") {
|
|
||||||
display += ";"; // springt over obstakel
|
|
||||||
} else {
|
|
||||||
display += ".";
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
display += world[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
document.title = display;
|
|
||||||
|
|
||||||
// jump logica
|
|
||||||
if (jumping) {
|
|
||||||
jumpFrames--;
|
|
||||||
if (jumpFrames <= 0) jumping = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// space = jump
|
|
||||||
document.addEventListener("keydown", e => {
|
|
||||||
if (e.code === "Space" && !jumping) {
|
|
||||||
jumping = true;
|
|
||||||
jumpFrames = 4;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
setInterval(gameTick, 180);
|
|
||||||
</script>
|
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
Reference in New Issue
Block a user