| 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 "pic.h" |
| 33 |
#include "thing.h" |
| 34 |
|
| 35 |
typedef enum |
| 36 |
{ |
| 37 |
PARTICLE_PIC, |
| 38 |
PARTICLE_TEXT |
| 39 |
} ParticleType; |
| 40 |
ParticleType StrParticleType(const char *s); |
| 41 |
|
| 42 |
typedef struct |
| 43 |
{ |
| 44 |
char *Name; |
| 45 |
ParticleType Type; |
| 46 |
union |
| 47 |
{ |
| 48 |
CPic Pic; |
| 49 |
struct |
| 50 |
{ |
| 51 |
char *Value; |
| 52 |
color_t Mask; |
| 53 |
} Text; |
| 54 |
} u; |
| 55 |
|
| 56 |
int RangeLow; |
| 57 |
int RangeHigh; |
| 58 |
float GravityFactor; |
| 59 |
bool HitsWalls; |
| 60 |
bool Bounces; |
| 61 |
float BounceFriction; |
| 62 |
bool WallBounces; |
| 63 |
bool ZDarken; |
| 64 |
bool DrawBelow; |
| 65 |
bool DrawAbove; |
| 66 |
} ParticleClass; |
| 67 |
typedef struct |
| 68 |
{ |
| 69 |
CArray Classes; |
| 70 |
CArray CustomClasses; |
| 71 |
} ParticleClasses; |
| 72 |
extern ParticleClasses gParticleClasses; |
| 73 |
|
| 74 |
typedef struct |
| 75 |
{ |
| 76 |
const ParticleClass *Class; |
| 77 |
union |
| 78 |
{ |
| 79 |
CPic Pic; |
| 80 |
char *Text; |
| 81 |
} u; |
| 82 |
int ActorUID; |
| 83 |
struct vec2 Pos; |
| 84 |
float Z; |
| 85 |
double Angle; |
| 86 |
float DZ; |
| 87 |
double Spin; |
| 88 |
int Count; |
| 89 |
int Range; |
| 90 |
Thing thing; |
| 91 |
bool isInUse; |
| 92 |
} Particle; |
| 93 |
extern CArray gParticles; |
| 94 |
|
| 95 |
typedef struct |
| 96 |
{ |
| 97 |
const ParticleClass *Class; |
| 98 |
int ActorUID; |
| 99 |
struct vec2 Pos; |
| 100 |
float Z; |
| 101 |
struct vec2 Vel; |
| 102 |
double Angle; |
| 103 |
float DZ; |
| 104 |
double Spin; |
| 105 |
struct vec2 DrawScale; |
| 106 |
color_t Mask; |
| 107 |
char Text[128]; |
| 108 |
} AddParticle; |
| 109 |
|
| 110 |
void ParticleClassesInit(ParticleClasses *classes, const char *filename); |
| 111 |
void ParticleClassesLoadJSON(CArray *classes, json_t *root); |
| 112 |
void ParticleClassesTerminate(ParticleClasses *classes); |
| 113 |
void ParticleClassesClear(CArray *classes); |
| 114 |
const ParticleClass *StrParticleClass( |
| 115 |
const ParticleClasses *classes, const char *name); |
| 116 |
|
| 117 |
void ParticlesInit(CArray *particles); |
| 118 |
void ParticlesTerminate(CArray *particles); |
| 119 |
void ParticlesUpdate(CArray *particles, const int ticks); |
| 120 |
|
| 121 |
int ParticleAdd(CArray *particles, const AddParticle add); |
| 122 |
void ParticleDestroy(CArray *particles, const int id); |