Skip to content

Conversation

@mariovisic
Copy link
Contributor

There's only a few small changes to the code in the actual Sprite class. The big change is moving the flipping code to the Vertices class so it can be re-used later by Tileset and then we get cropping and flipping for free there :)

All of the sprite C code can go as we're using Image and Texture to do out rendering now.

Lastly i've updated the methods which load SDL textures externally to be class methods as they don't have any state and in Sprite we need to load an image texture, so class method is easier :)

I've tested the sprite manually and it looks like it matches the main branch. The animations all look like they're working

Screen Shot 2021-08-11 at 11 55 16 am

Scaling also seems to work:

Screen Shot 2021-08-11 at 11 55 50 am

The Vertices class didn't have crop functionality which is required for
sprites, so that has been added in now :)

The internal flip_ variables inside the sprite can now be removed as the
Vertices class is now responsible for transforming the width/height/x and y
co-ordinates when flipping the image.
This sprite code is no longer used as we're using Image and Texture to
do our rendering now, and we calculate transforms like
scaling/cropping/rotating and mirroring in the Vertices ruby class.
We can add exception / error handling in the `ext_load_image` method rather than
directly in the sprite.
@blacktm blacktm merged commit ae55385 into ruby2d:main Aug 11, 2021
@mariovisic mariovisic deleted the sprite_rendering_refactor branch August 11, 2021 21:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants