diff --git a/src/cub3d_data.h b/src/cub3d_data.h index 43d1389..5549f26 100644 --- a/src/cub3d_data.h +++ b/src/cub3d_data.h @@ -40,6 +40,7 @@ typedef struct s_cub3d_data t_mapdata *map; t_player player; t_keypresses keypresses; + int door_amount; int *screen_matrix; int last_since_shoot; // temp int delta; diff --git a/src/map/collision.c b/src/map/collision.c index fbc2335..5837574 100644 --- a/src/map/collision.c +++ b/src/map/collision.c @@ -25,7 +25,7 @@ static bool out_of_bounds(t_mapdata *data, int x, int y) bool blocks_movement(t_mapdata *data, int x, int y) { - if (out_of_bounds(data, x, y) || ft_strchr("12345678d", data->map[y][x])) + if (out_of_bounds(data, x, y) || ft_strchr("12345678dP", data->map[y][x])) return (true); return (false); } diff --git a/src/player/pay.c b/src/player/pay.c index 0d4f1a7..9436875 100644 --- a/src/player/pay.c +++ b/src/player/pay.c @@ -13,15 +13,7 @@ #include "../cub3d_data.h" #include "../../libft/includes/libft.h" -int door_amount(void) -{ - static int amount = 500; - - amount += 250; - return (amount); -} - -bool pay(t_cub3d_data *data, int amount) +bool pay(t_cub3d_data *data, int amount, bool isdoor) { if (data->player.points < amount) { @@ -29,5 +21,7 @@ bool pay(t_cub3d_data *data, int amount) return (false); } data->player.points -= amount; + if (isdoor) + data->door_amount += 250; return (true); } diff --git a/src/player/pay.h b/src/player/pay.h index f656239..20959e5 100644 --- a/src/player/pay.h +++ b/src/player/pay.h @@ -15,7 +15,6 @@ # include "../cub3d_data.h" -int door_amount(void); -bool pay(t_cub3d_data *data, int amount); +bool pay(t_cub3d_data *data, int amount, bool isdoor); #endif // PAY_H diff --git a/src/raycast/ray.c b/src/raycast/ray.c index 04b42b6..cbd4cd9 100644 --- a/src/raycast/ray.c +++ b/src/raycast/ray.c @@ -63,7 +63,7 @@ void handle_door_ray(t_ray *ray, t_cub3d_data *data) { if ((data->map->map[ray->map_y][ray->map_x] == 'd' || data->map->map[ray->map_y][ray->map_x] == 'i' || data->map->map[ray->map_y][ray->map_x] == 'P') && ray->wall_dist < 1.5) { - ft_printf("map[%d][%d] = door reachable\n", ray->map_y, ray->map_x); + //ft_printf("map[%d][%d] = door reachable\n", ray->map_y, ray->map_x); data->player.closest_door[0] = ray->map_x; data->player.closest_door[1] = ray->map_y; data->player.can_open_door = true; @@ -72,7 +72,7 @@ void handle_door_ray(t_ray *ray, t_cub3d_data *data) data->keypresses.is_f_pressed = false; if (data->map->map[ray->map_y][ray->map_x] == 'd') data->map->map[ray->map_y][ray->map_x] = 'i'; - else if (data->map->map[ray->map_y][ray->map_x] == 'P' && pay(data, door_amount())) + else if (data->map->map[ray->map_y][ray->map_x] == 'P' && pay(data, data->door_amount, true)) data->map->map[ray->map_y][ray->map_x] = '0'; else if (data->map->map[ray->map_y][ray->map_x] == 'i') data->map->map[ray->map_y][ray->map_x] = 'd'; diff --git a/src/utils/inits.c b/src/utils/inits.c index 865299c..fc7fa11 100644 --- a/src/utils/inits.c +++ b/src/utils/inits.c @@ -113,5 +113,6 @@ void init_cub3d_data(t_cub3d_data *data, char **argv) load_textures(data); data->sprite_list = ft_calloc(sizeof(t_sprite *), MAX_SPRITES); ft_memset(data->sprite_distances, -1, MAX_SPRITES); + data->door_amount = 750; place_base_sprites(data, data->map->map); }