Repeating texture / repeating sprites?

I have a pattern like this -
image

what are the options for having the texture repeat? it seems like the only options are -

  1. make a tilemap
  2. just make a long texture with the repeating pattern baked in

are there other ways? are there performance concerns with either approach?

The central pattern looks to be 7x9 (flanked by stripes that could just be solid lines/rectangles).

If you close the gap between the "X"s then it could fit into an 8x8 pattern you could use to fill shapes at will:

playdate.graphics.setPattern(image, [x, y])

Docs link

For example you could draw a big white rectangle, a black one within that to clear the center, and then a rectangle of your "X" pattern.

(Or use pattern hex codes—annoying to figure out, but you only have to do it once!)

1 Like

ah neat! thanks for that tip. this is presumably pretty fast and low on memory requirements I guess?

(not that I'm hitting memory constraints at all, I'm just trying to get a feel for things here)

Yes, I've found it to be fast. Not sure how it would compare to a whole pre-rendered image in your specific case though.

(There are also "dither patterns"—which can apply your pattern to other things you're drawing, like a mask.)

There are also "dither patterns"—which can apply your pattern to other things you're drawing, like a mask

this sounds pretty neat! so you could do like a dissolve effect or something I guess?

Yes, although there are many ways to do dissolve effects and speed varies! drawFaded has been the speed champ for me.

2 Likes