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;