-
-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Direct spritesheet support #93
Comments
A It's not there yet because there are many different approaches we could take and I had a hard time choosing one. Thus, I preferred to leave it up to users to implement one and wait until we see a pattern or a common approach, and design based on that. Ideally, I would like something as type-safe as possible (i.e. something that avoids referencing sprites out of bounds, like the For instance, enums work well for item sprites, but once you add animation into the mix they become a hassle. Overall, I am unsure if there is a generic approach to satisfy most use cases here without promoting bad practice. We may be missing additional concepts, maybe we need different types of sprite sheets... I will keep thinking about it! If anyone has built something similar or has any ideas, feel free to share your thoughts here. It may help us find a good solution. @RantingBob Meanwhile, for your use case, if you need to refer individually to each sprite, I would use an enum and have a struct wrapping an |
I don't have any ideas at this time. I'll implement something and come back to you. As an aside, Batch vs Image for spritesheets? |
@RantingBob |
I just started messing around with Coffee, but this is what I made to handle sprite sheets. Functionality is very basic, but seems to work ok. Still needs some sanity checking like making sure a requested sprite is actually within bounds or that a given image can fit the stated number of rows and columns.
Usage in Game::draw is like this:
Feel free to use it. Might be an ok starting point. |
I currently have the following really basic function:
Which is basically a really hacky way to get a Rectangle that represents an area of a spritesheet. I'm likely to create an enum of all the sprites in the spritesheet, but I was wondering if there was some "better" way to do this in the actual engine. A SpriteSheet that wraps an Image and takes grid coords rather than a quad maybe? Or some way to load a spritesheet from which you can get the source rectangle for a given sprite?
It may be that the best way to do it is indeed for me to create myself a tilemap class, that the renderer owns and have an enum that the renderer knows how to convert into a rectangle, but I thought I'd bring this up.
The text was updated successfully, but these errors were encountered: