added sys digger

This commit is contained in:
verboomp
2026-04-20 16:09:18 +02:00
parent 510f12725e
commit 1e7b21a935
3 changed files with 122 additions and 5 deletions

View File

@@ -79,6 +79,7 @@ function topScore() {
let score = 0;
let docks = 0;
let gameOver = false;
let gameStarted = false;
let incomingAtoms = [];
let anchorPoints = [];
let particles = [];
@@ -177,19 +178,26 @@ function submitScore() {
function restartGame() {
score = docks = 0;
gameOver = false;
gameStarted = false;
incomingAtoms = [];
particles = [];
clickEffects = [];
lastSpawn = 0;
spawnInterval = SPAWN_INTERVAL_START;
document.getElementById('score').textContent = 'Score: 0';
document.getElementById('docks-count').textContent = '0 / 8 docks';
document.getElementById('docks-count').textContent = `0 / ${MAX_DOCKS} docks`;
document.getElementById('name-form').style.display = 'flex';
document.getElementById('overlay').classList.remove('active');
document.getElementById('intro').classList.remove('hidden');
initAnchors();
updateCystinstein();
}
function startGame() {
gameStarted = true;
document.getElementById('intro').classList.add('hidden');
}
function updateHudBest(best) {
document.getElementById('highscore').textContent = best !== null ? `Best: ${best}` : 'Best: —';
}
@@ -203,7 +211,7 @@ document.getElementById('player-name').addEventListener('keydown', e => {
function gameLoop(ts) {
drawBackground();
if (!gameOver && ts - lastSpawn > spawnInterval) {
if (gameStarted && !gameOver && ts - lastSpawn > spawnInterval) {
spawnAtom();
lastSpawn = ts;
spawnInterval = Math.max(SPAWN_INTERVAL_MIN, spawnInterval - SPAWN_DIFFICULTY_STEP);
@@ -221,6 +229,9 @@ function gameLoop(ts) {
}
// ─── Boot ────────────────────────────────────────────────────────────────────
// Fill dynamic value in intro text
document.getElementById('intro').innerHTML =
document.getElementById('intro').innerHTML.replace('${MAX_DOCKS}', MAX_DOCKS);
updateHudBest(topScore());
initAnchors();
updateCystinstein();