Log In  
Follow
weitnow

Hello together

I just started with pico8, lua and game-programming. I am trying to make a small fighting game and have a question concering animations. I want the player-sprite to be idle and if i click a button it should respond instantly and play an animation. Is there a way I could write the function "punching" with less code? Sprite Number 17, 18 and 19 are the sprites for a punching animation. The function first checks if the current sprite is between 17 or 19...if not it sets it to 17 (start of the punching animation)...then it iterats through the animation and checks again if the sprite is greater then 19 to set it back to 17. I have the feeling I have to much code in it...especially that I check twice if player.sp is greater then 19. Is there a more efficient way? Thanks in advance :)

function _init()
    player={
        sp=1,
        x=59,
        y=59,
        anim=0,
        state="idle",
        flp=false,
    }
end

function _update()

[ [size=16][color=#ffaabb] [ Continue Reading.. ] [/color][/size] ](/bbs/?pid=75555#p)
7 comments