#include "CrabClaw/types.h"#include "CrabClaw/screen.h"#include "CrabClaw/texture.h"Data Structures | |
| struct | cc_sprite |
| CrabClaw managed sprites. More... | |
| struct | cc_sprite_anim |
| Sprite animations. More... | |
| struct | cc_sprite_anim_frame |
| Sprite animation frame. More... | |
Typedefs | |
| typedef struct cc_sprite_anim_frame | cc_sprite_anim_frame_t |
| Sprite animation frame. | |
| typedef struct cc_sprite_anim | cc_sprite_anim_t |
| Sprite animations. | |
| typedef struct cc_sprite | cc_sprite_t |
| CrabClaw managed sprites. | |
Functions | |
| int | cc_sprite_add_anim (cc_sprite_t *dst, cc_sprite_anim_t *anim) |
| Add an animation to a sprite. | |
| int | cc_sprite_add_subsprite (cc_sprite_t *dst, cc_sprite_t *sub) |
| Add a sub-sprite to a sprite. | |
| void | cc_sprite_anim_reset (cc_sprite_anim_t *anim) |
| Reset an animation. | |
| void | cc_sprite_anim_update (cc_sprite_anim_t *anim) |
| Update an animation. | |
| int | cc_sprite_create_multi (cc_sprite_t *dst, int frames, int w, int h) |
| Create a sprite from multiple textures. | |
| int | cc_sprite_create_single (cc_sprite_t *dst, cc_texture_t *txr, float du, float dv) |
| Create a sprite from a single texture. | |
| void | cc_sprite_destroy (cc_sprite_t *spr) |
| Destroy a sprite. | |
| void | cc_sprite_draw (cc_sprite_t *spr, cc_screen_t *scr) |
| Draw a sprite to the screen. | |
| void | cc_sprite_draw_ex (cc_sprite_t *spr, cc_screen_t *scr, float xoff, float yoff, float zoff) |
| Draw a sprite to the screen. | |
| int | cc_sprite_load_anim (const char *fn, cc_sprite_anim_t *anim) |
| Load an animation from a text representation. | |
| void | cc_sprite_move (cc_sprite_t *spr, float dx, float dy, float dz) |
| Move a sprite. | |
| int | cc_sprite_set_animation (cc_sprite_t *spr, int anim) |
| Set the current animation of a sprite. | |
| int | cc_sprite_set_frame_multi (cc_sprite_t *spr, int frame) |
| Set the displayed frame of a sprite. | |
| int | cc_sprite_set_frame_single (cc_sprite_t *spr, uint32 xframe, uint32 yframe) |
| Set the displayed frame of a sprite. | |
| void | cc_sprite_set_position (cc_sprite_t *spr, float x, float y, float z) |
| Set the position of a sprite. | |
| void | cc_sprite_set_size (cc_sprite_t *spr, float w, float h) |
| Set the displayed size of a sprite. | |
| int | cc_sprite_set_texture (cc_sprite_t *spr, int num, cc_texture_t *txr) |
| Set a texture in a multi-image sprite. | |
| typedef struct cc_sprite_anim_frame cc_sprite_anim_frame_t |
Sprite animation frame.
Each frame of each animation has one cc_sprite_anim_frame_t object associated with it. This object describes the position in the cc_texture_t that this frame resides.
| typedef struct cc_sprite_anim cc_sprite_anim_t |
Sprite animations.
This class provides to the sprite code the ability to have animations. This struct consists primarily of a list of frames to display.
| typedef struct cc_sprite cc_sprite_t |
CrabClaw managed sprites.
This structure contains the data needed to implement a common sprite type along with supporting various enhancements such as animations. All fields of this structure should be considered to be read-only from outside CrabClaw.
| int cc_sprite_add_anim | ( | cc_sprite_t * | dst, | |
| cc_sprite_anim_t * | anim | |||
| ) |
Add an animation to a sprite.
This function attaches an animation to the given sprite.
| dst | The sprite to receive the animation. | |
| anim | The animation to attach. |
| int cc_sprite_add_subsprite | ( | cc_sprite_t * | dst, | |
| cc_sprite_t * | sub | |||
| ) |
Add a sub-sprite to a sprite.
This function attaches another sprite to the destination sprite. This other sprite will be drawn any time the parent is drawn, and will be offset by its set position from the upper-left corner of the parent.
| dst | The parent sprite. | |
| sub | The child sprite. |
| void cc_sprite_anim_reset | ( | cc_sprite_anim_t * | anim | ) |
Reset an animation.
This function resets the millisecond count and frame displayed to their initial values.
| anim | The animation to reset. |
| void cc_sprite_anim_update | ( | cc_sprite_anim_t * | anim | ) |
Update an animation.
This function updates the millisecond counter and the frame index if appropriate.
| anim | The animation to update. |
| int cc_sprite_create_multi | ( | cc_sprite_t * | dst, | |
| int | frames, | |||
| int | w, | |||
| int | h | |||
| ) |
Create a sprite from multiple textures.
This function creates a sprite that will be based off of a series of separate textures. This is the recommended way of doing things.
| dst | The destination for the sprite. | |
| frames | The number of frames. | |
| w | The width, in pixels of each frame. | |
| h | The height, in pixels of each frame. |
| int cc_sprite_create_single | ( | cc_sprite_t * | dst, | |
| cc_texture_t * | txr, | |||
| float | du, | |||
| float | dv | |||
| ) |
Create a sprite from a single texture.
This function creates a sprite that will be based off of one single sprite sheet texture.
| dst | The destination for the sprite. | |
| txr | The texture to use. | |
| du | 1.0f / number of frames across horizontally. | |
| dv | 1.0f / number of frames down vertically. |
| void cc_sprite_destroy | ( | cc_sprite_t * | spr | ) |
Destroy a sprite.
This function cleans up resources associated with the given sprite.
| spr | The sprite to clean up. |
| void cc_sprite_draw | ( | cc_sprite_t * | spr, | |
| cc_screen_t * | scr | |||
| ) |
Draw a sprite to the screen.
This function draws the given sprite to the cc_screen_t object passed in at the coordinates maintained in the sprite's data.
| spr | The sprite to draw. | |
| scr | The screen to draw to. |
| void cc_sprite_draw_ex | ( | cc_sprite_t * | spr, | |
| cc_screen_t * | scr, | |||
| float | xoff, | |||
| float | yoff, | |||
| float | zoff | |||
| ) |
Draw a sprite to the screen.
This function draws the given sprite to the cc_screen_t object passed in at the coordinates maintained in the sprite's data, offset by the offests passed in.
| spr | The sprite to draw. | |
| scr | The screen to draw to. | |
| xoff | The offset on the x axis. | |
| yoff | The offset on the y axis. | |
| zoff | The offset on the z axis. |
| int cc_sprite_load_anim | ( | const char * | fn, | |
| cc_sprite_anim_t * | anim | |||
| ) |
Load an animation from a text representation.
This function loads a text representation of an animation to the specified cc_sprite_anim_t object.
| fn | The file to load the animation from. | |
| anim | The destination for the animation. |
| void cc_sprite_move | ( | cc_sprite_t * | spr, | |
| float | dx, | |||
| float | dy, | |||
| float | dz | |||
| ) |
Move a sprite.
This function moves the position of the given sprite by the offsets given.
| spr | The sprite to move. | |
| dx | The distance to move on the x axis. | |
| dy | The distance to move on the y axis. | |
| dz | The distance to move on the z axis. |
| int cc_sprite_set_animation | ( | cc_sprite_t * | spr, | |
| int | anim | |||
| ) |
Set the current animation of a sprite.
This function sets the currently-in-use animation for the given sprite.
| spr | The sprite to set the animation of. | |
| anim | The index of the animation to set, or -1 for none. |
| int cc_sprite_set_frame_multi | ( | cc_sprite_t * | spr, | |
| int | frame | |||
| ) |
Set the displayed frame of a sprite.
This function sets the displayed frame of a sprite based on multiple textures. This function should only be called on sprites created with cc_sprite_create_multi.
| spr | The sprite to set the frame of. | |
| frame | The frame to display. |
| int cc_sprite_set_frame_single | ( | cc_sprite_t * | spr, | |
| uint32 | xframe, | |||
| uint32 | yframe | |||
| ) |
Set the displayed frame of a sprite.
This function sets the displayed frame of a sprite based on a single texture. This function should only be called on sprites created with cc_sprite_create_single.
| spr | The sprite to set the frame of. | |
| xframe | The frame across the spritesheet to set. | |
| yframe | The frame down the spritesheet to set. |
| void cc_sprite_set_position | ( | cc_sprite_t * | spr, | |
| float | x, | |||
| float | y, | |||
| float | z | |||
| ) |
Set the position of a sprite.
This function sets the postion of the given sprite to the coordinates provided.
| spr | The sprite to set the position of. | |
| x | The x position of the sprite. | |
| y | The y position of the sprite. | |
| z | The z position of the sprite. |
| void cc_sprite_set_size | ( | cc_sprite_t * | spr, | |
| float | w, | |||
| float | h | |||
| ) |
Set the displayed size of a sprite.
This function sets the size that the given sprite is displayed on screen.
| spr | The sprite to set the size of. | |
| w | The width of the sprite. | |
| h | The height of the sprite. |
| int cc_sprite_set_texture | ( | cc_sprite_t * | spr, | |
| int | num, | |||
| cc_texture_t * | txr | |||
| ) |
Set a texture in a multi-image sprite.
This function sets a texture in the multiple-texture sprite to the given texture.
| spr | The sprite to set the texture in. | |
| num | The texture number to set. | |
| txr | The texture to set. |