A retro platform game
git clone git://soophie.de/freezo
279
player->target_entity = NULL;280
player->shooting_distance = PLAYER_SHOOTING_RANGE;281
}282
// detect shooting wall/solid283
for (int i = 0; i < game->tiles_len; i++) {284
tile_t *tile = game->tiles[i];285
if (tile_wall(tile) || tile_solid(tile)) {286
rect_t tile_rect = { tile->pos.x, tile->pos.y, TILE_WIDTH, TILE_HEIGHT };287
if (rect_collide(shooting_rect, tile_rect)) {288
if (player->dir > 0) {289
player->shooting_distance = tile->pos.x - (player->pos.x + PLAYER_WIDTH);290
player->target_entity = NULL;291
}292
else {293
player->shooting_distance = player->pos.x - (tile->pos.x + TILE_WIDTH);294
player->target_entity = NULL;295
}296
}297
}298
}299
}300
else {301
player->target_entity = NULL;