1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
|
#ifndef __SPRITE_H__
#define __SPRITE_H__
#include <SDL/SDL.h>
/*! \brief Simple sprite struct
*/
struct sprite {
Uint32 start_tick;
SDL_Surface **surface_ptr;
Uint16 surface_count;
Uint16 speed_divisor;
};
/*! \brief Draw a sprite
*
* It will draw a sprite while animating it.
*
* \param sprite pointer to a sprite struct
* \param x x-position
* \param y y-position
* \param target target surface
* \param now return from SDL_GetTicks, used for selecting the frame
* \return return value of SDL_BlitSurface
*/
int draw_sprite(struct sprite *sprite, Sint16 x, Sint16 y,
SDL_Surface * target, Uint32 now);
/*! \brief get current image
* \param sprite sprite pointer
* \param now return from SDL_GetTicks
* \return the current surface
*/
SDL_Surface *get_current_sprite_surface(struct sprite *sprite, Uint32 now);
/*! Initialise a sprite struct
*
* \param sprite pointer to a sprite
* \param surfaces pointer to an array of surfaces
* \param surface_count number of surfaces in this array
* \param delay delay in ms for each frame
* \param now return from SDL_GetTicks
*/
void init_sprite(struct sprite *sprite, SDL_Surface ** surfaces,
Uint16 surface_count, Uint16 delay, Uint32 now);
#endif
|