Loading...
Searching...
No Matches
sprite.h File Reference
`#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"`

Go to the source code of this file.

## Typedefs

typedef struct ARC_Sprite | ARC_Sprite
| a sprite type
typedef enum ARC_Sprite_Axis | ARC_Sprite_Axix

## Enumerations

enum | ARC_Sprite_Axis { ARC_SPRITE_AXIS_NONE = 0x00 , ARC_SPRITE_AXIS_Y = 0x01 , ARC_SPRITE_AXIS_X = 0x02 }

## Functions

void | ARC_Sprite_Create (ARC_Sprite **sprite, ARC_Spritesheet *spritesheet, ARC_Array *frames)
| creates ARC_Sprite type
void | ARC_Sprite_Destroy (ARC_Sprite *sprite)
| destroys ARC_Sprite type
void | ARC_Sprite_Copy (ARC_Sprite **newSprite, ARC_Sprite *oldSprite)
| copies ARC_Sprite to a new ARC_Sprite
void | ARC_Sprite_SetOpacity (ARC_Sprite *sprite, uint8_t opacity)
| sets ARC_Sprite's opacity
void | ARC_Sprite_Render (ARC_Sprite *sprite, ARC_Renderer *renderer, ARC_Rect *renderBounds)
| renders ARC_Sprite type
void | ARC_Sprite_RenderFlip (ARC_Sprite *sprite, ARC_Renderer *renderer, ARC_Rect *renderBounds, enum ARC_Sprite_Axis axis)
| renders ARC_Sprite type with flip
void | ARC_Sprite_RenderRotated (ARC_Sprite *sprite, ARC_Renderer *renderer, ARC_Rect *renderBounds, ARC_Point *center, double angle)
| renders ARC_Sprite type with rotation
void | ARC_Sprite_SetFrameIndex (ARC_Sprite *sprite, uint32_t index)
| switches ARC_Sprite's frame to specified index
void | ARC_Sprite_IterateFrame (ARC_Sprite *sprite)
| switches ARC_Sprite's frames to next for animation
uint32_t | ARC_Sprite_GetFrameIndex (ARC_Sprite *sprite)
| gets ARC_Sprite's current frame
ARC_Rect * | ARC_Sprite_GetBounds (ARC_Sprite *sprite)
| returns the current bounds based on the ARC_Sprite's frames
ARC_Array * | ARC_Sprite_GetAllBounds (ARC_Sprite *sprite)
| returns the array of bounds that a sprite has

## Typedef Documentation

## ARC_Sprite

typedef struct ARC_Sprite ARC_Sprite

a sprite type

Note
  the actual type should be define by overriding for a graphics api

Definition at line 19 of file sprite.h.

## ARC_Sprite_Axix

typedef enum ARC_Sprite_Axis ARC_Sprite_Axix

## Enumeration Type Documentation

## ARC_Sprite_Axis

enum ARC_Sprite_Axis

Enumerator
ARC_SPRITE_AXIS_NONE |
ARC_SPRITE_AXIS_Y |
ARC_SPRITE_AXIS_X |

Definition at line 67 of file sprite.h.

{
ARC_SPRITE_AXIS_NONE = 0x00,
ARC_SPRITE_AXIS_Y = 0x01,
ARC_SPRITE_AXIS_X = 0x02,
} ARC_Sprite_Axix;
ARC_SPRITE_AXIS_Y
@ ARC_SPRITE_AXIS_Y
Definition sprite.h:69
ARC_SPRITE_AXIS_NONE
@ ARC_SPRITE_AXIS_NONE
Definition sprite.h:68
ARC_SPRITE_AXIS_X
@ ARC_SPRITE_AXIS_X
Definition sprite.h:70
ARC_Sprite_Axix
enum ARC_Sprite_Axis ARC_Sprite_Axix

## Function Documentation

## ARC_Sprite_Copy()

void ARC_Sprite_Copy | ( | ARC_Sprite ** | newSprite,
|  | ARC_Sprite * | oldSprite )

copies ARC_Sprite to a new ARC_Sprite

Parameters

  newSprite | ARC_Sprite that is being copied to and created
  oldSprite | ARC_Sprite contents that are being copied

## ARC_Sprite_Create()

void ARC_Sprite_Create | ( | ARC_Sprite ** | sprite,
|  | ARC_Spritesheet * | spritesheet,
|  | ARC_Array * | frames )

creates ARC_Sprite type

Parameters

  sprite | ARC_Sprite that is being created
  spritesheet | ARC_Spritesheet that ARC_Sprite will be pulled from
  frames | ARC_Array of bounds of sprite on spritesheet

## ARC_Sprite_Destroy()

void ARC_Sprite_Destroy | ( | ARC_Sprite * | sprite | ) |

destroys ARC_Sprite type

Parameters

  sprite | ARC_Sprite to destroy

## ARC_Sprite_GetAllBounds()

ARC_Array * ARC_Sprite_GetAllBounds | ( | ARC_Sprite * | sprite | ) |

returns the array of bounds that a sprite has

Parameters

  sprite | ARC_Sprite to get all the bounds from

## ARC_Sprite_GetBounds()

ARC_Rect * ARC_Sprite_GetBounds | ( | ARC_Sprite * | sprite | ) |

returns the current bounds based on the ARC_Sprite's frames

Parameters

  sprite | ARC_Sprite to get bounds from

## ARC_Sprite_GetFrameIndex()

uint32_t ARC_Sprite_GetFrameIndex | ( | ARC_Sprite * | sprite | ) |

gets ARC_Sprite's current frame

Parameters

  sprite | ARC_Sprite to get frame from

Returns
  index ARC_Sprite's current frame index

## ARC_Sprite_IterateFrame()

void ARC_Sprite_IterateFrame | ( | ARC_Sprite * | sprite | ) |

switches ARC_Sprite's frames to next for animation

Parameters

  sprite | ARC_Sprite that is having its frame updated

## ARC_Sprite_Render()

void ARC_Sprite_Render | ( | ARC_Sprite * | sprite,
|  | ARC_Renderer * | renderer,
|  | ARC_Rect * | renderBounds )

renders ARC_Sprite type

Parameters

  sprite | ARC_Sprite that will be rendered
  renderer | ARC_Renderer that is handling rendering
  renderBounds | area of renderer that ARC_Sprite will be rendered to

## ARC_Sprite_RenderFlip()

void ARC_Sprite_RenderFlip | ( | ARC_Sprite * | sprite,
|  | ARC_Renderer * | renderer,
|  | ARC_Rect * | renderBounds,
|  | enum ARC_Sprite_Axis | axis )

renders ARC_Sprite type with flip

Parameters

  sprite | ARC_Sprite that will be rendered
  renderer | ARC_Renderer that is handling rendering
  renderBounds | area of renderer that ARC_Sprite will be rendered to
  axis | axis to flip sprite

## ARC_Sprite_RenderRotated()

void ARC_Sprite_RenderRotated | ( | ARC_Sprite * | sprite,
|  | ARC_Renderer * | renderer,
|  | ARC_Rect * | renderBounds,
|  | ARC_Point * | center,
|  | double | angle )

renders ARC_Sprite type with rotation

Parameters

  sprite | ARC_Sprite that will be rendered
  renderer | ARC_Renderer that is handling rendering
  renderBounds | area of renderer that ARC_Sprite will be rendered to
  angle | angle to rotate ARC_Sprite
  center | point to rotate ARC_Sprite around

## ARC_Sprite_SetFrameIndex()

void ARC_Sprite_SetFrameIndex | ( | ARC_Sprite * | sprite,
|  | uint32_t | index )

switches ARC_Sprite's frame to specified index

Parameters

  sprite | ARC_Sprite that is having its frame set
  index | uint32_t to set ARC_Sprite's frame index to

## ARC_Sprite_SetOpacity()

void ARC_Sprite_SetOpacity | ( | ARC_Sprite * | sprite,
|  | uint8_t | opacity )

sets ARC_Sprite's opacity

Parameters

  sprite | ARC_Sprite that is changing opacity
  opacity | new opacity for ARC_Sprite

Note
  this is temp because opacity probably should be a value bigger than 255