| 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 |
#pragma once |
| 29 |
|
| 30 |
#include <json/json.h> |
| 31 |
|
| 32 |
#include "defs.h" |
| 33 |
#include "grafx.h" |
| 34 |
#include "pic.h" |
| 35 |
|
| 36 |
typedef struct |
| 37 |
{ |
| 38 |
Pic pic; |
| 39 |
char *name; |
| 40 |
} NamedPic; |
| 41 |
typedef struct |
| 42 |
{ |
| 43 |
CArray pics; |
| 44 |
char *name; |
| 45 |
} NamedSprites; |
| 46 |
|
| 47 |
typedef enum |
| 48 |
{ |
| 49 |
PICTYPE_NORMAL, |
| 50 |
PICTYPE_DIRECTIONAL, |
| 51 |
PICTYPE_ANIMATED, |
| 52 |
PICTYPE_ANIMATED_RANDOM |
| 53 |
} PicType; |
| 54 |
PicType StrPicType(const char *s); |
| 55 |
|
| 56 |
typedef struct |
| 57 |
{ |
| 58 |
PicType Type; |
| 59 |
union |
| 60 |
{ |
| 61 |
const Pic *Pic; |
| 62 |
const CArray *Sprites; |
| 63 |
struct |
| 64 |
{ |
| 65 |
const CArray *Sprites; |
| 66 |
int Count; |
| 67 |
int Frame; |
| 68 |
int TicksPerFrame; |
| 69 |
} Animated; |
| 70 |
} u; |
| 71 |
color_t Mask; |
| 72 |
} CPic; |
| 73 |
typedef struct |
| 74 |
{ |
| 75 |
direction_e Dir; |
| 76 |
struct vec2i Offset; |
| 77 |
double Radians; |
| 78 |
struct vec2 Scale; |
| 79 |
color_t Mask; |
| 80 |
SDL_RendererFlip Flip; |
| 81 |
} CPicDrawContext; |
| 82 |
CPicDrawContext CPicDrawContextNew(void); |
| 83 |
typedef void (*DrawCPicFunc)(GraphicsDevice *, const int, const struct vec2i); |
| 84 |
|
| 85 |
void NamedPicFree(NamedPic *n); |
| 86 |
|
| 87 |
void NamedSpritesInit(NamedSprites *ns, const char *name); |
| 88 |
void NamedSpritesFree(NamedSprites *ns); |
| 89 |
|
| 90 |
void CPicLoadJSON(CPic *p, json_t *node); |
| 91 |
void CPicInitNormal(CPic *p, const Pic *pic); |
| 92 |
void CPicInitNormalFromName(CPic *p, const char *name); |
| 93 |
void CPicLoadNormal(CPic *p, const json_t *node); |
| 94 |
bool CPicIsLoaded(const CPic *p); |
| 95 |
struct vec2i CPicGetSize(const CPic *p); |
| 96 |
|
| 97 |
void CPicCopyPic(CPic *dest, const CPic *src); |
| 98 |
void CPicUpdate(CPic *p, const int ticks); |
| 99 |
const Pic *CPicGetPic(const CPic *p, const int idx); |
| 100 |
void CPicDraw( |
| 101 |
GraphicsDevice *g, const CPic *p, |
| 102 |
const struct vec2i pos, const CPicDrawContext *context); |