Private
Public Access
1
0

bug fixes
All checks were successful
Dynamic Branch Deploy / build-and-deploy (push) Successful in 3m42s

This commit is contained in:
Sebastian Unterschütz
2025-11-26 10:59:05 +01:00
parent fc8b22dd7c
commit 95119cdf98
4 changed files with 191 additions and 69 deletions

View File

@@ -1,70 +1,84 @@
function updateGameLogic() {
// 1. Speed Berechnung (Sync mit Server!)
let currentSpeed = BASE_SPEED + (score / 1000);
if (currentSpeed > 10.0) currentSpeed = 10.0;
// 2. Input & Sprung
if (isCrouching) inputLog.push({ t: currentTick - lastSentTick, act: "DUCK" });
const originalHeight = 50; const crouchHeight = 25;
player.h = isCrouching ? crouchHeight : originalHeight;
let drawY = isCrouching ? player.y + (originalHeight - crouchHeight) : player.y;
// Jump Power Check
let jumpP = JUMP_POWER;
if (bootTicks > 0) {
jumpP = HIGH_JUMP_POWER;
bootTicks--;
// 1. Input Logging (Ducken)
if (isCrouching) {
inputLog.push({ t: currentTick - lastSentTick, act: "DUCK" });
}
// Physik
// 2. Geschwindigkeit (Basiert auf ZEIT/Ticks, nicht Score!)
// Formel: Start bei 5, erhöht sich alle 3000 Ticks (ca. 50 Sek) um 0.5
let currentSpeed = 5 + (currentTick / 3000.0) * 0.5;
if (currentSpeed > 12.0) currentSpeed = 12.0; // Max Speed Cap
// 3. Spieler Physik & Größe
const originalHeight = 50;
const crouchHeight = 25;
player.h = isCrouching ? crouchHeight : originalHeight;
// Visuelle Korrektur Y (damit Füße am Boden bleiben)
let drawY = isCrouching ? player.y + (originalHeight - crouchHeight) : player.y;
// Schwerkraft
player.vy += GRAVITY;
if (isCrouching && !player.grounded) player.vy += 2.0;
if (isCrouching && !player.grounded) player.vy += 2.0; // Schneller fallen (Fast Fall)
player.y += player.vy;
// Boden-Kollision
if (player.y + originalHeight >= GROUND_Y) {
player.y = GROUND_Y - originalHeight; player.vy = 0; player.grounded = true;
} else { player.grounded = false; }
player.y = GROUND_Y - originalHeight;
player.vy = 0;
player.grounded = true;
} else {
player.grounded = false;
}
// 3. Obstacles
// 4. Hindernisse Bewegen & Kollision
let nextObstacles = [];
let rightmostX = 0;
for (let obs of obstacles) {
obs.x -= currentSpeed;
// Hitbox für aktuellen Frame
const playerHitbox = { x: player.x, y: drawY, w: player.w, h: player.h };
if (checkCollision(playerHitbox, obs)) {
// TYPE CHECK
// A. MÜNZE (+2000 Punkte)
if (obs.def.type === "coin") {
score += 2000;
continue;
continue; // Entfernen (Eingesammelt)
}
// B. POWERUP (Aktivieren)
else if (obs.def.type === "powerup") {
if (obs.def.id === "p_god") godModeLives = 3;
if (obs.def.id === "p_bat") hasBat = true;
if (obs.def.id === "p_boot") bootTicks = 600;
continue;
if (obs.def.id === "p_boot") bootTicks = 600; // ca. 10 Sekunden
continue; // Entfernen (Eingesammelt)
}
// C. GEGNER / HINDERNIS
else {
// HINDERNIS
// Schläger vs Lehrer
if (hasBat && obs.def.type === "teacher") {
hasBat = false;
continue; // Zerstört!
hasBat = false; // Schläger kaputt
continue; // Lehrer weg
}
// Godmode vs Alles
if (godModeLives > 0) {
godModeLives--;
continue; // Überlebt!
godModeLives--; // Ein Leben weg
continue; // Hindernis ignoriert
}
// Tod
player.color = "darkred";
if (!isGameOver) { sendChunk(); gameOver("Kollision"); }
if (!isGameOver) {
sendChunk();
gameOver("Kollision");
}
}
}
// Objekt behalten wenn noch im Bild
if (obs.x + obs.def.width > -100) {
nextObstacles.push(obs);
if (obs.x + obs.def.width > rightmostX) rightmostX = obs.x + obs.def.width;
@@ -72,42 +86,52 @@ function updateGameLogic() {
}
obstacles = nextObstacles;
// 4. Spawning (Sync mit Go!)
// 5. Spawning (Basiert auf ZEIT/Ticks)
if (rightmostX < GAME_WIDTH - 10 && gameConfig) {
const gap = Math.floor(400 + rng.nextRange(0, 500));
let spawnX = rightmostX + gap; if (spawnX < GAME_WIDTH) spawnX = GAME_WIDTH;
let spawnX = rightmostX + gap;
if (spawnX < GAME_WIDTH) spawnX = GAME_WIDTH;
const isBossPhase = (score % 1500) > 1200;
// Boss Phase abhängig von Zeit (nicht Score, wegen Münzen!)
const isBossPhase = (currentTick % 1500) > 1200;
let possibleObs = [];
gameConfig.obstacles.forEach(def => {
if (isBossPhase) {
// Boss Phase: Nur Principal und Trashcan
if (def.id === "principal" || def.id === "trashcan") possibleObs.push(def);
} else {
// Normal Phase
if (def.id === "principal") return;
if (def.id === "eraser" && score < 500) return;
// Eraser erst ab Tick 3000 (ca. 50 Sek)
if (def.id === "eraser" && currentTick < 3000) return;
possibleObs.push(def);
}
});
// Zufälliges Objekt wählen
let def = rng.pick(possibleObs);
// Speech Sync
// RNG Sync: Sprechblasen
let speech = null;
if (def && def.canTalk) {
// WICHTIG: Reihenfolge muss 1:1 wie in Go sein
if (rng.nextFloat() > 0.7) speech = rng.pick(def.speechLines);
}
// Powerup Rarity Sync (Muss exakt wie Go sein: 10% Chance)
// RNG Sync: Powerup Seltenheit (nur 10% Chance)
if (def && def.type === "powerup") {
if (rng.nextFloat() > 0.1) def = null;
}
// Hinzufügen
if (def) {
const yOffset = def.yOffset || 0;
obstacles.push({
x: spawnX, y: GROUND_Y - def.height - yOffset,
def: def, speech: speech
x: spawnX,
y: GROUND_Y - def.height - yOffset,
def: def,
speech: speech
});
}
}