summaryrefslogtreecommitdiff
path: root/in_practice/breakout/particle.h
blob: 3e5d9a680bec8fc75a63f372b283330f1cf7a376 (plain)
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
#ifndef PARTICLE_H
#define PARTICLE_H

#include "my_math.h"
#include "object.h"

struct particle {
	v2 pos;
	v2 vel;
	v4 color;
	f32 life;
};

#define default_particle { \
	.pos = {0.0f, 0.0f}, \
	.vel = {0.0f, 0.0f}, \
	.color = {1.0f, 1.0f, 1.0f, 1.0f}, \
	.life = 0.0f \
}

#define MAX_PARTICLES 500

struct particle_generator {
	struct particle particles[MAX_PARTICLES];
	i32 new;
	u32 shader;
	u32 texture;
	u32 vao;
};

void respawn_particle(struct particle *particle, struct object object, v2 offset);
i32 find_unused_particle(struct particle_generator generator);
struct particle_generator init_generator(i32 new, u32 shader, u32 texture);
void update_particles(struct particle_generator *generator, struct object object, f32 dt, v2 offset);
void render_particles(struct particle_generator generator);
void reset_particles(struct particle_generator *generator);

#endif