mirror of
https://codeberg.org/ACME-Corporation/cub3d.git
synced 2025-12-06 01:48:08 +01:00
feat: finished payed doors
This commit is contained in:
parent
5cc6988c9c
commit
94fd8779e2
6 changed files with 9 additions and 14 deletions
|
|
@ -40,6 +40,7 @@ typedef struct s_cub3d_data
|
||||||
t_mapdata *map;
|
t_mapdata *map;
|
||||||
t_player player;
|
t_player player;
|
||||||
t_keypresses keypresses;
|
t_keypresses keypresses;
|
||||||
|
int door_amount;
|
||||||
int *screen_matrix;
|
int *screen_matrix;
|
||||||
int last_since_shoot; // temp
|
int last_since_shoot; // temp
|
||||||
int delta;
|
int delta;
|
||||||
|
|
|
||||||
|
|
@ -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)
|
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 (true);
|
||||||
return (false);
|
return (false);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,15 +13,7 @@
|
||||||
#include "../cub3d_data.h"
|
#include "../cub3d_data.h"
|
||||||
#include "../../libft/includes/libft.h"
|
#include "../../libft/includes/libft.h"
|
||||||
|
|
||||||
int door_amount(void)
|
bool pay(t_cub3d_data *data, int amount, bool isdoor)
|
||||||
{
|
|
||||||
static int amount = 500;
|
|
||||||
|
|
||||||
amount += 250;
|
|
||||||
return (amount);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool pay(t_cub3d_data *data, int amount)
|
|
||||||
{
|
{
|
||||||
if (data->player.points < amount)
|
if (data->player.points < amount)
|
||||||
{
|
{
|
||||||
|
|
@ -29,5 +21,7 @@ bool pay(t_cub3d_data *data, int amount)
|
||||||
return (false);
|
return (false);
|
||||||
}
|
}
|
||||||
data->player.points -= amount;
|
data->player.points -= amount;
|
||||||
|
if (isdoor)
|
||||||
|
data->door_amount += 250;
|
||||||
return (true);
|
return (true);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,6 @@
|
||||||
|
|
||||||
# include "../cub3d_data.h"
|
# include "../cub3d_data.h"
|
||||||
|
|
||||||
int door_amount(void);
|
bool pay(t_cub3d_data *data, int amount, bool isdoor);
|
||||||
bool pay(t_cub3d_data *data, int amount);
|
|
||||||
|
|
||||||
#endif // PAY_H
|
#endif // PAY_H
|
||||||
|
|
|
||||||
|
|
@ -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)
|
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[0] = ray->map_x;
|
||||||
data->player.closest_door[1] = ray->map_y;
|
data->player.closest_door[1] = ray->map_y;
|
||||||
data->player.can_open_door = true;
|
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;
|
data->keypresses.is_f_pressed = false;
|
||||||
if (data->map->map[ray->map_y][ray->map_x] == 'd')
|
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] = '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';
|
data->map->map[ray->map_y][ray->map_x] = '0';
|
||||||
else if (data->map->map[ray->map_y][ray->map_x] == 'i')
|
else if (data->map->map[ray->map_y][ray->map_x] == 'i')
|
||||||
data->map->map[ray->map_y][ray->map_x] = 'd';
|
data->map->map[ray->map_y][ray->map_x] = 'd';
|
||||||
|
|
|
||||||
|
|
@ -113,5 +113,6 @@ void init_cub3d_data(t_cub3d_data *data, char **argv)
|
||||||
load_textures(data);
|
load_textures(data);
|
||||||
data->sprite_list = ft_calloc(sizeof(t_sprite *), MAX_SPRITES);
|
data->sprite_list = ft_calloc(sizeof(t_sprite *), MAX_SPRITES);
|
||||||
ft_memset(data->sprite_distances, -1, MAX_SPRITES);
|
ft_memset(data->sprite_distances, -1, MAX_SPRITES);
|
||||||
|
data->door_amount = 750;
|
||||||
place_base_sprites(data, data->map->map);
|
place_base_sprites(data, data->map->map);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue