graphics icon indicating copy to clipboard operation
graphics copied to clipboard

How best to compose sprites?

Open JoshCheek opened this issue 7 years ago • 1 comments

Playing around with sprites to see how they compose. blit attaches them at the center point of the sprite. It took quite a bit of effort to figure that out and then figure out how to put the sprite in the right spot, given that information. I didn't understand how to do it until I drew a lot more lines on the screen so I could see why things were moving the way they were:

https://gist.github.com/JoshCheek/505d6722e80786461d04cbe8ede3c290#file-1_attach_at_bottom_mid-rb-L225-L230 composing_sprites_1


Since the trees were going in a single direction, I felt like their branches should be billowing in the wind, so I reworked the them to do that. This caused them to be entirely contained in the bottom right quadrant of their sprite. With some versions, they would occasionally go beneath the ground, out of the sprite's viewport. I'm not sure how to get things out of the viewport to be visible other than to make the sprite larger and move the starting point inward. But if I move the starting point, eg if I remove the 3 irrelevant quadrants and have the tree's trunk grow from the bottom left, then I also have to edit the code that determines where the sprite attaches, which is rather unappealing. https://gist.github.com/JoshCheek/505d6722e80786461d04cbe8ede3c290#file-2_attach_at_bottom_left-rb

composing_sprites_2


Not sure if I don't understand how to compose sprites, or if this is just not how sprites were meant to be used (eg this is probably where the Graphics::Body is most useful). Just figured I'd ask if others have a good approach to composition and how they deal with the need to attach at different points without a lot of code churn.

JoshCheek avatar Nov 23 '16 12:11 JoshCheek

Can you look at this now? It looks nicer to me, but I don't know what you're going for exactly.

Also, blit centers, but put uses lower left, if that helps.

zenspider avatar Oct 25 '18 05:10 zenspider