ouzvoutc7tczutctcztczgczgcz
This commit is contained in:
parent
ae7b1e61bc
commit
323e27648d
38
js/allg.js
38
js/allg.js
@ -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)';
|
||||
}
|
||||
});
|
@ -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";
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user