Log In  


Cart #yemirutfa-0 | 2022-09-05 | Code ▽ | Embed ▽ | No License
1


Hello, I'm looking for a way to draw 100 sprites on the screen at the same time. All sprites will have different coordinates. I don't want to write 100 times spr(), so I"m looking for another way. I wanted to use a loop, but from what I've noticed so far, the pico 8 has performance issues after that. Does anyone have any idea what to do with it?

1


It all depends upon if you are moving or animating them or not, @Kowalik_13.

If not, you can plot them once and then forget about them.

If they do animate, you might have something like this, which really does not take very much CPU.

Cart #dazufogake-0 | 2022-09-05 | Code ▽ | Embed ▽ | No License

Press CTRL+P while it is running to see that even moving 100-sprites only takes 7% of Pico-8's CPU.


In my game, I would like to insert 100 sprites first and then, when a player tags one and clicks the button, the sprite will disappear.


@dw817 Thanks for help.


It looks like the map function (and map drawing tool) would fit your needs


@Kowalik_13

Agree with @dredds if your sprites are consistently on an 8x8 grid.

If not, 100 calls to spr() really aren't that bad if you can get a tight loop around the calls. It's only something like 10(?) virtual cpu cycles (can't remember exactly) of overhead per spr(n,x,y) call and you get about 136k cycles per frame at 60fps, so 1000 cycles of overhead is nothing. The remainder of the draw cost you'd pay regardless since the API costs are per pixel and you're still drawing the same number of pixels.


Thanks everyone for your advice.



[Please log in to post a comment]