diff options
author | citrons <citrons@mondecitronne.com> | 2023-10-14 01:14:03 -0500 |
---|---|---|
committer | citrons <citrons@mondecitronne.com> | 2023-10-14 01:14:03 -0500 |
commit | 689c24dc77aac53416f6cb8b38362284ff64f308 (patch) | |
tree | 34bb5b2a559a3d8aaca28b0845be2524429ef0fd | |
parent | b7f85312f7e45d28dcd92efa8dd1a35149d9b3c9 (diff) |
do not consume light unless tile has actually been placed
-rw-r--r-- | world.c | 6 |
1 files changed, 3 insertions, 3 deletions
@@ -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]--; } } } |