crystal-tower/src/shatter.c

29 lines
642 B
C

#include "shatter.h"
#include "anim.h"
#include "conf.h"
#include "level.h"
#include "particles.h"
#include "tile.h"
#include "vec.h"
#include <gint/display.h>
static void callback(struct Anim *);
void
shatter(int x, int y)
{
extern bopti_image_t bimg_shatter;
const int ax = (int)(x / TILE_SIZE) * TILE_SIZE;
const int ay = (int)(y / TILE_SIZE) * TILE_SIZE;
struct Anim p = anim_new(&bimg_shatter, ax, ay, TILE_SIZE, 2, false);
p.callback = callback;
if (level_get_px(ax, ay) == TILE_SOLID && !particles_here(ax, ay))
particles_add(p);
}
static void
callback(struct Anim *a)
{
level_set_px(a->pos.x, a->pos.y, TILE_SHATTERED);
}