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 |
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.
[Please log in to post a comment]