This commit is contained in:
Jan Breitkreuz 2024-08-29 08:18:22 +02:00
parent 5980e2e42c
commit d8d20a7b3c

View File

@ -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;