#include "shatter.h" #include "anim.h" #include "conf.h" #include "level.h" #include "particles.h" #include "raygint/display.h" #include "tile.h" #include "vec.h" #include static void callback(struct Anim *); void shatter(int x, int y) { #ifdef GINT extern bopti_image_t bimg_shatter; #endif #ifdef RAYLIB bopti_image_t bimg_shatter = 0; #endif 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) { const int x = a->pos.x / TILE_SIZE; const int y = a->pos.y / TILE_SIZE; level_set(x, y, TILE_SHATTERED); if (level_get(x - 1, y) == TILE_SPIKE_L) level_set(x - 1, y, TILE_VOID); if (level_get(x + 1, y) == TILE_SPIKE_R) level_set(x + 1, y, TILE_VOID); if (level_get(x, y - 1) == TILE_SPIKE_U) level_set(x, y - 1, TILE_VOID); if (level_get(x, y + 1) == TILE_SPIKE_D) level_set(x, y + 1, TILE_VOID); }