From 689c24dc77aac53416f6cb8b38362284ff64f308 Mon Sep 17 00:00:00 2001 From: citrons Date: Sat, 14 Oct 2023 01:14:03 -0500 Subject: do not consume light unless tile has actually been placed --- world.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/world.c b/world.c index 8899ff6..6d40110 100644 --- a/world.c +++ b/world.c @@ -170,20 +170,20 @@ void player_collect(world *w, SDL_Point pos) { void player_place(world *w, int x, int y) { if (!player_grounded(w)) return; if (!SDL_TICKS_PASSED(SDL_GetTicks(), w->player.place_wait)) return; - if (w->player.scores[TILE_LIGHT] < 1) return; - - w->player.scores[TILE_LIGHT]--; w->player.place_wait = SDL_GetTicks() + PLAYER_PLACE_DELAY; + if (w->player.scores[TILE_LIGHT] < 1) return; SDL_Point place = {w->player.pos.x + x, w->player.pos.y + y}; if (!is_solid(get_tile(w, place))) { player_collect(w, place); set_tile(w, place, TILE_BLOCK_WHITE); + w->player.scores[TILE_LIGHT]--; } else { SDL_Point push = {w->player.pos.x - x, w->player.pos.y - y}; if (!is_solid(get_tile(w, push))) { set_tile(w, w->player.pos, TILE_BLOCK_WHITE); w->player.pos = push; + w->player.scores[TILE_LIGHT]--; } } } -- cgit v1.2.3