pd-rs / crankstart

A barely functional, wildly incomplete and basically undocumented Rust crate whose aim is to let you write Games for the Playdate handheld gaming system in Rust.
MIT License
235 stars 24 forks source link

Add text and rotated sprite helpers #38

Closed tjkirch closed 1 year ago

tjkirch commented 1 year ago

Fixes #35 more fully.

It's a best practice to use sprites for text, but managing sprites and bitmaps and drawing (and figuring out the requisite heights/widths) is a little more complicated than I'd like for simple text. The first commit adds a TextSprite helper that does that for you, with access to the underlying Sprite for normal sprite methods.

Similarly, another commit adds RotatedSprite which handles storing and rotating a given bitmap and its owning Sprite. It also allows for scaling, since that's bundled in the same Playdate APIs. Plus binding methods.

Finally, a third commit adds get_image so you can inspect the generated bitmaps of the above, in case that's useful.