17cupsofcoffee / tetra

🎮 A simple 2D game framework written in Rust
MIT License
909 stars 63 forks source link

Horizontal and vertical flip #262

Open fossegutten opened 3 years ago

fossegutten commented 3 years ago

Summary: Add booleans for horizontal and vertical flip to DrawParams, that does not offset the textures. This would be nice because scaling in negative direction also offsets the texture in the negative direction. As a workaround to avoid this, we need to add half texture size to position and to origin.

Steps to reproduce:

DrawParams::default()
                .position(some_position)
                .scale(Vec2::new(-1.0, -1.0))

Texture now moved up and to the left.

Expected behavior: Expected the texture to draw at some_position, just mirrored.

Additional info:

17cupsofcoffee commented 3 years ago

This definitely does seem like something worth adding (XNA has it via SpriteEffects). I'd just need to figure out if there's a way to do it without a breaking change - because DrawParams has pub fields and no non_exhaustive annotation, it could break people's code if I added a new field (but it might be minor enough to be worth it).