I have a simple program that only loads a sprite and rotates it:
import "CoreLibs/sprites"
local gfx = playdate.graphics
local beam = gfx.sprite.new(gfx.image.new("tex/beam.png"))
beam: moveTo(200,120)
beam: add()
beam: setRotation(178)
beam: update()
For some unfortunate rotation numbers, it crashes in 70% of the cases on both simulator and device. 178 being one of them. 177 or 179 don't cause the game to crash. (beam: update() is not necessary to crash it).
I can't really read the crash report, but maybe these are the important lines:
This sounds like a bug I've fixed in the next update, coming soon: I was passing the floating-point width and height of the rotated image to the allocator/initializer function (which reads them as ints, so they were truncated) but then I used ceil() when passing them to the drawing function, leading to an out-of-bounds write in certain cases.
However, I found out that rotating two 400px images is very expensive for the framerate – even more expensive than loading an image? If I rotate them, the frame rate drops to ~15–20. Is that normal?
Yes, playdate has cheap space and expensive cpu time. If you want to rotate sprites - prerender images, load them to RAM as imagetable then change images as sprite rotates. Daily Driver once had 360 rotated images for each car...