Update index.php

This commit is contained in:
2025-12-29 20:41:21 +01:00
parent 515829ecb9
commit 463ef9eac7

View File

@@ -1,43 +1,61 @@
<?php <?php
// PHP startpunt (kan later scores / sessions doen) // later kan hier PHP score / sessions
?> ?>
<!DOCTYPE html> <!DOCTYPE html>
<html lang="nl"> <html lang="nl">
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<title>T-REX</title> <title>loading...</title>
</head> </head>
<body> <body>
<h1>T-Rex Run (in de tab 😎)</h1> <h1>Kijk naar de tab 👆</h1>
<p>Kijk naar de titel van dit tabblad</p>
<script> <script>
let trex = "🦖"; // vaste dino positie
let ground = "____________________"; const dinoPos = 5;
let pos = 0;
let dir = 1;
let score = 0;
function updateTitle() { // wereld (komma = obstakel)
let before = ground.substring(0, pos); let world = " , , , ";
let after = ground.substring(pos + 2); let jumping = false;
let jumpFrames = 0;
// obstakel function gameTick() {
let obstacle = (score % 10 === 0) ? "::" : " "; // wereld schuift naar links
world = world.slice(1) + (Math.random() < 0.15 ? "," : " ");
document.title = let display = "";
before + trex + after + obstacle + " score:" + score; for (let i = 0; i < world.length; i++) {
if (i === dinoPos) {
pos += dir; // dino
if (pos <= 0 || pos >= ground.length - 2) { if (jumping && world[i] === ",") {
dir *= -1; display += ";"; // springt over obstakel
} else {
display += ".";
}
} else {
display += world[i];
}
} }
score++; document.title = display;
// jump logica
if (jumping) {
jumpFrames--;
if (jumpFrames <= 0) jumping = false;
}
} }
setInterval(updateTitle, 200); // space = jump
document.addEventListener("keydown", e => {
if (e.code === "Space" && !jumping) {
jumping = true;
jumpFrames = 4;
}
});
setInterval(gameTick, 180);
</script> </script>
</body> </body>