Jump to content
  • Advertisement
Sign in to follow this  

How to use a sprite whci have many position for my hero

This topic is 4450 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

This is my problem .. maybe it is a lazy question. I use C and lib allegro and i have problem when i need to draw and make an animation use only one picture(sprite) who have a lot of picture for my hero position . I know i can use a picture for each position at my hero or somtehing else ,but is not a according to the situation , i think http://www.sprites-inc.co.uk/files/Classic/DrWily/index.php - this is an exemple! .

Share this post

Link to post
Share on other sites
Requires that the sprites are arranged in a grid, each cell being the same size.

void drawSpriteMap(BITMAP *dest, // Bitmap to draw on
int x, // X position to draw at.
int y, // Y position to draw at.
BITMAP *spritemap, // The sprite map to use.
int h_num, // Horizontal number of sprites.
int v_num, // Vertical number of sprites.
int h_index, // Horizontal index of the sprite to use.
int v_index) // Vertical index of the sprite to use.
ASSERT(dest && spritemap);
ASSERT(h_num > 0 && v_num > 0);
ASSERT(h_index >= 0 && h_index < h_num);
ASSERT(v_index >= 0 && v_index < v_num);

masked_blit(spritemap, dest,
spritemap->w/h_num*h_index, spritemap->h/v_num*v_index,
x, y,
spritemap->w/h_num, spritemap->h/v_num);

[Edited by - smart_idiot on August 10, 2006 7:31:47 AM]

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!