Log In  

Cart #26683 | 2016-08-09 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA

Here I have played around a bit with animations. I have combined both sprite animations and particle animations to make it look good. The sprite animations are done with a "config" structure so that I can use the same functions for drawing the animations later. Actors and particles are seperated in there own tables. I think this is best if you want to do collision detection later.

Now I want to improve the code and what some suggestions. I have not used Lua and I am sure you can see that on the code. Currently it use 870 tokens. This must be improved I guess? I guess every token counts in the end when you are creating a complete game. But I think there is a lot of stuff that can be improved.

I do also have some questions. For example I update and delete disabled actors like this, is this safe? or can this result in that some actors are updated multiple times peer loop etc?

    for a in all(actors) do
        if(a.enabled) then
            a.update(a)
        else
            del(actors, a)
        end
    end
P#26684 2016-08-09 05:10 ( Edited 2016-08-09 10:47)

Re: update loop

I believe that's safe and will do as you expect; from the Pico-8 doc:

del t v

...
del() can be called safely on a table's item while iterating over that table.

Should just nick it out the table and continue with the subsequent table item on the next iteration.

P#26686 2016-08-09 06:47 ( Edited 2016-08-09 10:47)

[Please log in to post a comment]

Follow Lexaloffle:          
Generated 2024-03-28 14:17:33 | 0.011s | Q:12