Hhelp with animation !!
I need help. I created a prototype player code for an RPG... I created a line of code that says if the player presses Z, the attack animation should be "player," but it's not working. The only animation that works is the idle attack animation, which is behind the normal idle sprite. I don't know what to do. Please help me. Thank you. Here is my code :D
player = object
x = 0
y = 0
width = 52
height = 52
vitesse = 3
image = "idle"
move = false
canMove = true
direction = 0
invisible = false
mouvement = true
attack = false
colision_cube = object
x = 0
y = 0
width = 38
height = 44
end
end
end
updatePlayer = function()
local oldX = player.x
local oldY = player.y
player.direction = 0
player.move = false
if player.canMove == true then
if keyboard.UP then
player.y += player.vitesse
player.move = true
player.image = "up"
player.direction = 1
end
if keyboard.DOWN then
player.y -= player.vitesse
player.move = true
player.image = "down"
player.direction = -1
end
if keyboard.LEFT then
player.x -= player.vitesse
player.move = true
player.image = "left"
player.direction = 2
end
if keyboard.RIGHT then
player.x += player.vitesse
player.move = true
player.image = "right"
player.direction = -2
end
if not player.move then
player.image == "idle"
player.direction = 0
end
end
player.colision_cube.x = player.x
player.colision_cube.y = player.y
// CORRECTION : Boucle pour vérifier les obstacles
for w in list_solide
if checkCollision(player.colision_cube, w) then
player.x = oldX
player.y = oldY
player.colision_cube.x = oldX
player.colision_cube.y = oldY
end
end
end
if keyboard.Z then player.attack = true player.mouvement = false end
if player.attack == true and keyboard.K then player.attack = false end
if player.attack == true then
if player.direction == -2 then
player.image = "attack_right" end
if player.direction == 2 then
player.image = "attack_left" end
if player.direction == 1 then
player.image = "attack_up" end
if player.direction == -1 then
player.image = "attack_down"
end
if player.direction == 0 and not player.move then
player.image = "attack_idle" end
end
drawPlayer = function()
if not player.invisible then
screen.drawRect(player.colision_cube.x, player.colision_cube.y, player.colision_cube.width, player.colision_cube.height, "rgb(0,255,0)")
if player.image == "attack_up" then screen.drawSprite( "player/attack_up", player.x, player.y, player.width, player.height) end
if player.image == "attack_down" then screen.drawSprite( "player/attack_down", player.x, player.y, player.width, player.height) end
if player.image == "attack_left" then screen.drawSprite( "player/attacl_left", player.x, player.y, player.width, player.height) end
if player.image == "attack_right" then screen.drawSprite( "player/attack_right", player.x, player.y, player.width, player.height) end
if player.image == "attack_idle" then screen.drawSprite( "player/attack_idle", player.x, player.y, player.width, player.height ) end
if player.mouvement then
if player.image == "up" then screen.drawSprite( "player/player_up", player.x, player.y, player.width, player.height ) end
if player.image == "down" then screen.drawSprite( "player/player_down", player.x, player.y, player.width, player.height ) end
if player.image == "right" then screen.drawSprite( "player/player_right", player.x, player.y, player.width, player.height ) end
if player.image == "left" then screen.drawSprite( "player/player_left", player.x, player.y, player.width, player.height ) end
if not player.move then screen.drawSprite( "player/idle", player.x, player.y, player.width, player.height ) end
end
end
end


