55 lines
927 B
JavaScript
55 lines
927 B
JavaScript
let playerAnim = [];
|
|
let tomAnim = [];
|
|
let enemyAnim = [];
|
|
let playerAnimState = 0;
|
|
let player = document.querySelector("#fuchs img");
|
|
|
|
fillArrays();
|
|
|
|
function fillArrays()
|
|
{
|
|
fillArray("fuchs_", 8, playerAnim);
|
|
fillArray("tom_", 3, tomAnim);
|
|
fillArray("enemy_",3, enemyAnim);
|
|
}
|
|
|
|
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)';
|
|
}
|
|
}); |