ouzvoutc7tczutctcztczgczgcz

This commit is contained in:
Jan Breitkreuz 2024-06-27 10:31:37 +02:00
parent ae7b1e61bc
commit 323e27648d
2 changed files with 39 additions and 1 deletions

View File

@ -1,6 +1,8 @@
let playerAnim = [];
let tomAnim = [];
let enemyAnim = [];
let playerAnimState = 0;
let player = document.querySelector("#fuchs img");
fillArrays();
@ -15,3 +17,39 @@ playerAnim.forEach(function(player)
{
console.log(player);
});
let start = setInterval(gameLoop, 100);
function gameLoop()
{
playerRunAnim();
checkInput();
}
function playerRunAnim()
{
if(playerAnimState == 8)
{
playerAnimState = 0;
}
player.src = playerAnim[playerAnimState];
playerAnimState++;
}
function checkInput()
{
}
document.addEventListener('keydown', function(event) {
if(event.key == "d")
{
console.log("d");
player.style.transform = 'scaleX(1)';
}
else if(event.key == "a")
{
player.style.transform = 'scaleX(-1)';
}
});

View File

@ -2,6 +2,6 @@
function fillArray(name, number, playerAnim)
{
for (let i = 1 ; i <= number ; i++) {
playerAnim[i] = name + i + ".png";
playerAnim[i-1] = "pics/" + name + i + ".png";
}
}