A retro platform game
git clone git://soophie.de/freezo
diff --git a/src/player.c b/src/player.c
index 08b38f2..ad14b46 100644
--- a/src/player.c
+++ b/src/player.c
1
@@ -279,6 +279,23 @@ void player_update(player_t *player, game_t *game) {2
player->target_entity = NULL;3
player->shooting_distance = PLAYER_SHOOTING_RANGE;4
}5
+ // detect shooting wall/solid6
+ for (int i = 0; i < game->tiles_len; i++) {7
+ tile_t *tile = game->tiles[i];8
+ if (tile_wall(tile) || tile_solid(tile)) {9
+ rect_t tile_rect = { tile->pos.x, tile->pos.y, TILE_WIDTH, TILE_HEIGHT };10
+ if (rect_collide(shooting_rect, tile_rect)) {11
+ if (player->dir > 0) {12
+ player->shooting_distance = tile->pos.x - (player->pos.x + PLAYER_WIDTH);13
+ player->target_entity = NULL;14
+ }15
+ else {16
+ player->shooting_distance = player->pos.x - (tile->pos.x + TILE_WIDTH);17
+ player->target_entity = NULL;18
+ }19
+ }20
+ }21
+ }22
}23
else {24
player->target_entity = NULL;