Hey, is there a way to draw a rectangle of arbitrary dimension filled with tiled sprites, aka textured rectangle or tiled rectangle? I can of course manually iterate and draw the same sprites many times, but this had very bad performance so I quickly hit over 1 CPU (meaning I'm dropping from 60 to 30 FPS).
In other engines, you'd set sprite rendering mode to Tiled and stretch the sprite, resulting in a repeating pattern preserving the sprite original size, instead of stretching the original sprite like sspr.
Recently, we got textured lines (tline) and fill patterns (fillp) but there is no direct way to use them to draw tiled sprites.
I see some ways to do that, but they are all workarounds, with no one-line solution:
a. iterate on 2D coordinates and draw same sprite with spr() -> bad performance
b. prepare a tilemap of the same sprites and draw them, offset by some camera() with map() -> need to either setup tilemap in data or generate them at runtime, and need to think with reverse offset to set camera properly. Kind of a waste of data if your rectangle is always using the same sprite. Only works if you have spare space in your tilemap (or you must overwrite some tilemap data and restore it later; note that with Big Maps in PICO-8 0.2.4, it's less of an issue)
c. use fillp to set up a binary pattern and use it for rectfill -> only works for binary (2-color) sprites
I'm using a. for now, and only drawing sprites visible by at least 1px on screen to spare CPU, but even that costs too much (around 0.7 out of my budget of 0.1! and I need TWO layers of those because the foreground layer has some transparency, so I quickly get over CPU budget).
I think I'll be switching to b. for now.
sspr() could have an additional argument "render_mode_option". 0 is default of stretching, 1 is for tiled rendering.
[Please log in to post a comment]