fix README, SYNC, DATENSCHUTZ
Some checks failed
Dynamic Branch Deploy / build-and-deploy (push) Has been cancelled
Some checks failed
Dynamic Branch Deploy / build-and-deploy (push) Has been cancelled
This commit is contained in:
@@ -3,41 +3,31 @@
|
||||
// ==========================================
|
||||
|
||||
function handleInput(action, active) {
|
||||
// 1. Game Over Reset
|
||||
if (isGameOver) {
|
||||
if(active) location.reload();
|
||||
return;
|
||||
}
|
||||
|
||||
// 2. JUMP LOGIK
|
||||
if (action === "JUMP" && active) {
|
||||
// Wir prüfen lokal, ob wir springen dürfen (Client Prediction)
|
||||
if (player.grounded && !isCrouching) {
|
||||
|
||||
// A. Sofort lokal anwenden (damit es sich direkt anfühlt)
|
||||
player.vy = JUMP_POWER;
|
||||
player.grounded = false;
|
||||
|
||||
playSound('jump');
|
||||
spawnParticles(player.x + 15, player.y + 50, 'dust', 5); // Staubwolke an den Füßen
|
||||
|
||||
// B. An Server senden ("Ich habe JETZT gedrückt")
|
||||
// Die Funktion sendInput ist in network.js definiert
|
||||
if (typeof sendInput === "function") {
|
||||
sendInput("input", "JUMP");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 3. DUCK LOGIK
|
||||
if (action === "DUCK") {
|
||||
// Status merken, um unnötiges Senden zu vermeiden
|
||||
const wasCrouching = isCrouching;
|
||||
|
||||
// A. Lokal anwenden
|
||||
isCrouching = active;
|
||||
|
||||
// B. An Server senden (State Change: Start oder Ende)
|
||||
if (wasCrouching !== isCrouching) {
|
||||
if (typeof sendInput === "function") {
|
||||
sendInput("input", active ? "DUCK_START" : "DUCK_END");
|
||||
@@ -50,9 +40,9 @@ function handleInput(action, active) {
|
||||
// EVENT LISTENERS
|
||||
// ==========================================
|
||||
|
||||
// Tastatur
|
||||
|
||||
window.addEventListener('keydown', (e) => {
|
||||
// Ignorieren, wenn User gerade Name in Highscore tippt
|
||||
|
||||
if (e.target.tagName === 'INPUT' || e.target.tagName === 'TEXTAREA') return;
|
||||
|
||||
if (e.code === 'Space' || e.code === 'ArrowUp') handleInput("JUMP", true);
|
||||
@@ -61,7 +51,6 @@ window.addEventListener('keydown', (e) => {
|
||||
e.preventDefault();
|
||||
console.log("🐞 Fordere Debug-Daten vom Server an...");
|
||||
if (typeof sendInput === "function") {
|
||||
// Wir senden ein manuelles Paket, da sendInput meist nur für Game-Inputs ist
|
||||
if (socket && socket.readyState === WebSocket.OPEN) {
|
||||
socket.send(JSON.stringify({ type: "debug" }));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user