170 lines
4.7 KiB
C
170 lines
4.7 KiB
C
#ifndef ARC_GRAPHICS_SPRITE_H_
|
|
#define ARC_GRAPHICS_SPRITE_H_
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
#include "arc/graphics/renderer.h"
|
|
#include "arc/graphics/spritesheet.h"
|
|
#include "arc/math/point.h"
|
|
#include "arc/math/rectangle.h"
|
|
#include "arc/std/array.h"
|
|
|
|
/**
|
|
* @brief
|
|
*/
|
|
typedef enum ARC_SpriteAxis {
|
|
ARC_SPRITE_AXIS_NONE = 0x00,
|
|
ARC_SPRITE_AXIS_Y = 0x01,
|
|
ARC_SPRITE_AXIS_X = 0x02,
|
|
} ARC_SpriteAxix;
|
|
|
|
/**
|
|
* @brief a sprite type
|
|
*/
|
|
typedef struct ARC_Sprite {
|
|
ARC_Spritesheet *spritesheet;
|
|
ARC_Array frames;
|
|
uint32_t frameIndex;
|
|
|
|
double angle;
|
|
|
|
ARC_FPoint origin;
|
|
|
|
float opacity;
|
|
|
|
ARC_SpriteAxix axis;
|
|
|
|
float animationCurrentTime;
|
|
float animationTime;
|
|
} ARC_Sprite;
|
|
|
|
/**
|
|
* @brief creates ARC_Sprite type
|
|
*
|
|
* @param sprite ARC_Sprite that is being created
|
|
* @param spritesheet ARC_Spritesheet that ARC_Sprite will be pulled from
|
|
* @param frames ARC_Array of ARC_FRect bounds of sprite on spritesheet
|
|
*/
|
|
void ARC_Sprite_Create(ARC_Sprite **sprite, ARC_Spritesheet *spritesheet, ARC_Array frames);
|
|
|
|
/**
|
|
* @brief destroys ARC_Sprite type
|
|
*
|
|
* @param sprite ARC_Sprite to destroy
|
|
*/
|
|
void ARC_Sprite_Destroy(ARC_Sprite *sprite);
|
|
|
|
/**
|
|
* @brief copies ARC_Sprite to a new ARC_Sprite
|
|
*
|
|
* @param newSprite ARC_Sprite that is being copied to and created
|
|
* @param oldSprite ARC_Sprite contents that are being copied
|
|
*/
|
|
void ARC_Sprite_Copy(ARC_Sprite **newSprite, ARC_Sprite *oldSprite);
|
|
|
|
/**
|
|
* @brief renders ARC_Sprite type
|
|
*
|
|
* @param sprite ARC_Sprite that will be rendered
|
|
* @param renderer ARC_Renderer that is handling rendering
|
|
* @param renderBounds area of renderer that ARC_Sprite will be rendered to
|
|
*/
|
|
void ARC_Sprite_Render(ARC_Sprite *sprite, ARC_Renderer *renderer, ARC_FRect renderBounds);
|
|
|
|
/**
|
|
* @brief renders ARC_Sprite type at a point and at a set scale
|
|
*
|
|
* @param sprite ARC_Sprite that will be rendered
|
|
* @param renderer ARC_Renderer that is handling rendering
|
|
* @param point point on the renderer that ARC_Sprite will be rendered to (will be scaled as well)
|
|
* @param scale the scale to render at
|
|
*/
|
|
void ARC_Sprite_RenderAt(ARC_Sprite *sprite, ARC_Renderer *renderer, ARC_FPoint point, double scale);
|
|
|
|
/**
|
|
* @brief switches ARC_Sprite's frames to next for animation
|
|
*
|
|
* @param sprite ARC_Sprite that is having its frame updated
|
|
*/
|
|
void ARC_Sprite_IterateFrame(ARC_Sprite *sprite);
|
|
|
|
/**
|
|
* @brief switches ARC_Sprite's frames to next for animation
|
|
*
|
|
* @param sprite ARC_Sprite that is being animated (having its frame updated based on delta time)
|
|
* @param deltatime the ammount of time elapsed in seconds (stored as a float where 1.0 is a second) since last animated
|
|
*/
|
|
void ARC_Sprite_AnimateFrame(ARC_Sprite *sprite, float deltatime);
|
|
|
|
/**
|
|
* @brief switches ARC_Sprite's frame to specified index
|
|
*
|
|
* @param sprite ARC_Sprite that is having its frame set
|
|
* @param index uint32_t to set ARC_Sprite's frame index to
|
|
*/
|
|
void ARC_Sprite_SetFrameIndex(ARC_Sprite *sprite, uint32_t index);
|
|
|
|
/**
|
|
* @brief sets the origin point of the sprite (the rotation and position point)
|
|
*
|
|
* @param sprite ARC_Sprite that is having its angle set
|
|
* @param angle the given agnel in degrees to rotate around (rotated clockwise)
|
|
*/
|
|
void ARC_Sprite_SetAngle(ARC_Sprite *sprite, double angle);
|
|
|
|
/**
|
|
* @brief sets the origin point of the sprite (the rotation and position point)
|
|
*
|
|
* @param sprite ARC_Sprite that is having its origin set
|
|
* @param origin the point on the arc sprite (based on its bounds/frame) to rotate around
|
|
*/
|
|
void ARC_Sprite_SetOrigin(ARC_Sprite *sprite, ARC_FPoint origin);
|
|
|
|
/**
|
|
* @brief sets ARC_Sprite's opacity
|
|
*
|
|
* @note opacity is a float value between 0.0 and 1.0 (1.0 is fully opaque)
|
|
*
|
|
* @param sprite ARC_Sprite that is changing opacity
|
|
* @param opacity new opacity for ARC_Sprite
|
|
*/
|
|
void ARC_Sprite_SetOpacity(ARC_Sprite *sprite, float opacity);
|
|
|
|
/**
|
|
* @brief sets ARC_Sprite's framerate for
|
|
*
|
|
* @param sprite ARC_Sprite to change its frame rate
|
|
* @param rate the new framerate as a float in seconds (1.0 is one second)
|
|
*/
|
|
void ARC_Sprite_SetFrameRate(ARC_Sprite *sprite, float rate);
|
|
|
|
/**
|
|
* @brief gets ARC_Sprite's current frame
|
|
*
|
|
* @param sprite ARC_Sprite to get frame from
|
|
*
|
|
* @return index ARC_Sprite's current frame index
|
|
*/
|
|
uint32_t ARC_Sprite_GetFrameIndex(ARC_Sprite *sprite);
|
|
|
|
/**
|
|
* @brief returns the current bounds based on the ARC_Sprite's frames
|
|
*
|
|
* @param sprite ARC_Sprite to get bounds from
|
|
*/
|
|
ARC_FRect *ARC_Sprite_GetBounds(ARC_Sprite *sprite);
|
|
|
|
/**
|
|
* @brief returns the array of bounds that a sprite has
|
|
*
|
|
* @param sprite ARC_Sprite to get all the bounds from
|
|
*/
|
|
ARC_Array ARC_Sprite_GetAllBounds(ARC_Sprite *sprite);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif // !ARC_GRAPHICS_SPRITE_H_
|