crystal-tower/src/particles.c

52 lines
755 B
C

#include "particles.h"
#include "anim.h"
#include <stddef.h>
static struct Anim particles[MAX_PARTICLES];
void
particles_init(void)
{
int i = MAX_PARTICLES;
while (i-- > 0)
particles[i] = anim_new(NULL, 0, 0, 1, 0, 0);
}
void
particles_add(struct Anim a)
{
/* find empty spot */
int i = MAX_PARTICLES;
while (i-- > 0)
if (!particles[i].life)
break;
particles[i] = a;
}
void
particles_update(void)
{
int i = MAX_PARTICLES;
while (i-- > 0)
anim_update(&particles[i]);
}
void
particles_draw(void)
{
int i = MAX_PARTICLES;
while (i-- > 0)
anim_draw(&particles[i]);
}
int
particles_here(int x, int y)
{
int i = MAX_PARTICLES;
while (i-- > 0) {
if (particles[i].pos.x == x && particles[i].pos.y == y)
return 1;
}
return 0;
}