Animated sprites starting too early
Im back hooray, but im having an issue. I want to make a game and have a dude pull out a sword. But whenever he does this he will usually start too early, any fixes
sincerely DanMan97
init = function()
player_x = 0
player_y = 0
swordout = false
time1 = 0
end
update = function()
if keyboard.SPACE and swordout == false then
swordout = true
time1 = 50
end
if time1 > 0 then
time1 -= 0.5
end
end
draw = function()
screen.clear()
if swordout == false then
screen.drawSprite('player',player_x,player_y,30,30)
elsif swordout == true and time1 == 0 then
screen.drawSprite('swordout',player_x,player_y,30,30)
end
if swordout == true and time1 != 0 then
screen.drawSprite('swordpull',player_x,player_y,30,30)
end
end