Jump to content
  • Advertisement
Sign in to follow this  
nethackpro

SDL Sprites

This topic is 3074 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

So, up untill now, everything I've done with SDL has used used 32x32 tiles/sprites. So all my tilesets and character sheets were set up in perfect grids made up of 32x32 squares. Now I'm trying to use something more like this http://www.forsakenguild.com/sprites/Classes/Male_Sprites/Male_HighWizard.png Notice how they aren't all the same size? For example, the diagonal movement animations are thinner then forward movement animations. If I wanted to use a character sheet similar in style to this one, would I have to manually center and align everything? Or is there an easy way to handle dynamically sized sprites on the fly?

Share this post


Link to post
Share on other sites
Advertisement
If you look at the sprites you can see that the point of reference is the bottom. So basically you can align them to that point of reference.

A trick you can use is to keep all sprites the same size. Use the largest sprite and leave larger blank spaces on the smaller ones. In that case you do not have to care about different sized sprites.

Share this post


Link to post
Share on other sites
Quote:
Original post by rioki
If you look at the sprites you can see that the point of reference is the bottom. So basically you can align them to that point of reference.


Could you elaborate a little please? I'm not really familiar with the term "point of reference". But perhaps I'm not being totally clear myself..

In that picture, they are using 8 frames for each of the walking animations. But some frames are skinnier then others. How can I deal with these sprites without knowing their width ahead of time?

Share this post


Link to post
Share on other sites
What he means by "point of reference" is that the position that you refer to for sprites should be relative to the center of the bottom for each sprite. SDL blits the sprite from the upper-left coordinate so you need to store an offset so that you can keep all of the coordinates for your sprites pointing to where they meet the floor at the center of the bottom of each sprite.

For example, if you have a sprite that is 16 pixels wide and 32 pixels tall, your offset will be -8,-32. You add -8 to the x coordinate when you blit and add -32 to the y coordinate. This allows you to blit a tall sprite when the game itself only keeps track of where the sprite is standing on the floor. If you have another sprite that is 20 pixels wide and 48 pixels tall, your offsets will be -10, -48.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!