hecrj / coffee

An opinionated 2D game engine for Rust
https://docs.rs/coffee
MIT License
1.08k stars 55 forks source link

Add rotation support for Quad and Sprite #133

Open danheuck opened 4 years ago

danheuck commented 4 years ago

Added support for rotating individual Quads and Sprites as mentioned in #1. As a side effect, this ended up moving the anchor point for positions to the center of the Sprite/Quad since the Sprites needed to be centered on the origin before they could be rotated. In my opinion, this behavior is often preferable anyway, but I realize it's subjective. I can try to figure out a way to apply the rotation without moving changing the way sprite positioning works if desired, but I'm far from an expert on transformation matrices.

1 mentioned concerns that adding rotation support would negatively impact performance. I did not add any benchmarks, but anecdotally testing with the particles example did not show any significant difference with or without the change.

danheuck commented 4 years ago

Just added a few more commits that move the anchor point back to the top left corner and revert most of the changes I made to the UI renderers as a consequence of the anchor point moving.

KimPlaybit commented 1 year ago

I would like to see this merged aswell. Most games use this feature.