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?

P#116940 2022-09-05 19:24

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.

P#116943 2022-09-05 19:38 ( Edited 2022-09-05 19:45)

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.

P#116946 2022-09-05 19:55

@dw817 Thanks for help.

P#116948 2022-09-05 20:07

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

P#116949 2022-09-05 20:34

@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.

P#117050 2022-09-08 02:43 ( Edited 2022-09-08 03:10)

Thanks everyone for your advice.

P#117066 2022-09-08 12:06

[Please log in to post a comment]

Follow Lexaloffle:          
Generated 2024-03-29 08:03:24 | 0.047s | Q:31