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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
#ifndef FXS_H
#define FXS_H
#include <SDL2/SDL.h>
#define FXS_BULLET_MAX 4096
#define FXS_EXPLOSION_MAX 2048
typedef struct {
float from[2];
float to[2];
float starttime;
float endtime;
float size;
float color[3];
} bullet;
typedef struct {
float pos[2];
float vel[2];
float color[3];
float size;
float mass;
float lifetime;
} particle;
typedef struct {
float pos[2];
float force[2];
float friction;
particle parts[32];
int partslen;
float starttime;
} explosion;
typedef struct {
bullet *bullets;
int bulletslen;
explosion *explosions;
int explosionslen;
} fxs;
void fx_init (fxs *fx);
void fx_add_bullet (fxs *fx, bullet *b);
void fx_explosion_init (fxs *fx, explosion *e,
float pos[], float vel[], float color[], float force[],
float spread, float speed, int n, float time, float lifetime);
void fx_add_explosion (fxs *fx, explosion *e);
void fx_process (fxs *fx, float time);
void fx_render (SDL_Renderer *rend, fxs *fx, float cam[], float time);
#endif
|