From d8d20a7b3c3ea9324f19bb5ab19eb25049b0a2ec Mon Sep 17 00:00:00 2001 From: "NB-PBG2H23ABR\\bib" Date: Thu, 29 Aug 2024 08:18:22 +0200 Subject: [PATCH] bewegung --- js/allg.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/js/allg.js b/js/allg.js index 4b4e78d..d0c1dd7 100644 --- a/js/allg.js +++ b/js/allg.js @@ -6,7 +6,8 @@ let runDirection = 0; let runSpeed = 12; let animationSpeed = 50; let currentPosition = 0; -let player = document.querySelector("#fuchs img"); +let player = document.querySelector("#fuchs"); +let playerSprite = document.querySelector("#fuchs img"); let dIsPressed = false; let aIsPressed = false; let runAnimation; @@ -43,7 +44,7 @@ function playerRunAnim() { playerAnimState = 0; } - player.src = playerAnim[playerAnimState]; + playerSprite.src = playerAnim[playerAnimState]; playerAnimState++; } @@ -53,7 +54,7 @@ document.addEventListener('keydown', function(event) { { if(runDirection != 1) { - player.style.transform = 'scaleX(1)'; + playerSprite.style.transform = 'scaleX(1)'; } runDirection = 1; dIsPressed = true; @@ -62,7 +63,7 @@ document.addEventListener('keydown', function(event) { { if(runDirection != -1) { - player.style.transform = 'scaleX(-1)'; + playerSprite.style.transform = 'scaleX(-1)'; } runDirection = -1; aIsPressed = true;