I've submitted this cartridge to the WIP section because it is not finished, it does not have sound and it starts lagging like crazy after a minute. I would appreciate it if someone could tell me a way to store a table with the bullets and remove them once they are no longer visible. I have tried using the DEL() function, but it just changes a value into nil, which bugs the code.
How are the bullets stored in a table?
This is pretty much the way they are stored:
if btn(4) then -- storing the X so it stays there add(bullets, player_x) -- storing the Y, so it can be changed add(bullets, 100) end |
And this is how the table is read:
for i=1, #bullets do if i % 2 == 0 then -- change the y so that they go up bullets[i-1] -= 2 end end |
So I really need help finding a better way to store them and removing the unnecessary bullets.
This is my first thing I've made with Pico-8. Press Z/click to add a circle, and press X to clear.
How it works:
For every time you draw a circle it adds the X and Y of it to a table. Then, in the draw function, all circles in the table are rendered. I thought it was interesting how this rendered the circles so I published it for everyone to see.