v1.0 - normed texture system, multiple keypress, fixes on parsing, removed trailing maps

This commit is contained in:
B.Goulard 2024-12-16 14:56:22 +01:00
parent e581c72b02
commit 3f43074d05
35 changed files with 474 additions and 438 deletions

View file

@ -6,7 +6,7 @@
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/10/30 16:30:26 by rparodi #+# #+# */
/* Updated: 2024/12/05 16:45:30 by rparodi ### ########.fr */
/* Updated: 2024/12/16 14:48:17 by bgoulard ### ########.fr */
/* */
/* ************************************************************************** */
@ -22,9 +22,15 @@
# include <stdbool.h>
// raycasting
void draw_bg(t_info *data);
void set_step(t_ipoint *step, t_dpoint raydir);
void set_side_dist(t_dpoint *side_dist, t_dpoint *tb, t_ipoint pos_i);
t_texture *get_texture(int side, t_ipoint step, t_info *data);
void draw_(int *ti, double *td, t_ipoint step, t_info *data);
// utils
void draw_floor(t_info *data);
void dump_info(t_info *info);
int render_frame(t_info *data);
void my_mlx_pixel_put(t_info *data, int x, int y, int color);
double deg2rad(int deg);
@ -38,6 +44,9 @@ void move_backward(t_info *data);
void move_left(t_info *data);
void move_right(t_info *data);
int keyrelease_feature(int keycode, t_info *data);
int keypress_feature(int keycode, t_info *data);
int displacement_hook(t_info *data);
int get_cl(int side, t_ipoint step);
t_tile *c3_get_cell(t_tile *map, t_ipoint dimensions, t_ipoint pos);

View file

@ -6,7 +6,7 @@
/* By: bgoulard <bgoulard@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/11/28 13:53:54 by bgoulard #+# #+# */
/* Updated: 2024/12/01 18:01:48 by rparodi ### ########.fr */
/* Updated: 2024/12/16 14:15:43 by bgoulard ### ########.fr */
/* */
/* ************************************************************************** */
@ -18,7 +18,7 @@
# define FILE_EXTENSION ".cub"
# define FILE_EXTENSION_LEN 4
# define BG_CLG 0
# define BG_SKY 0
# define BG_FLR 1
# define TILE_SIZE 64
# define WIN_COEF .5
@ -26,8 +26,8 @@
// defines that should be mooved to a config option / file
# define FOV 70
# define ROT_SPEED 0.1
# define MOVE_SPEED 0.5
# define ROT_SPEED 0.004
# define MOVE_SPEED 0.008
// -- graphic utils
@ -132,12 +132,25 @@ typedef enum e_error
ERROR_MISSING_FILE,
ERROR_MALLOC,
ERROR_PARSE,
ERROR_MAP_OPEN,
ERROR_PARSE_BG_COLOR_FORMAT,
ERROR_PARSE_ALREADY_SET,
ERROR_CLI,
ERROR_MLX,
ERROR_TEXTURE_FORMAT,
ERROR_IMPLEM,
} t_error;
typedef struct s_kb
{
bool forward;
bool backward;
bool left;
bool right;
bool l_left;
bool l_right;
} t_keyboard;
typedef struct s_pixel_buffer
{
char *img_addr;
@ -153,11 +166,13 @@ typedef struct s_info
{
t_error last_error;
int errno_state;
t_keyboard kb;
t_xvar *mlx_ptr;
t_win_list *win_ptr;
t_ipoint screen_size;
t_pixel_buffer camera;
bool redraw;
t_map map;
t_player player;

32
includes/ft_addons.h Normal file
View file

@ -0,0 +1,32 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_addons.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: bgoulard <bgoulard@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/12/16 06:09:01 by bgoulard #+# #+# */
/* Updated: 2024/12/16 09:36:19 by bgoulard ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef FT_ADDONS_H
# include <stdbool.h>
// ft_addons
/// @brief Says if a value is in a range excluding the bounds
/// @param value The value to check
/// @param min The lower bound
/// @param max The upper bound
/// @return true if the value is in the range, false otherwise
bool ft_inrange_ex(int value, int min, int max);
/// @brief Says if a value is in a range including the bounds
/// @param value The value to check
/// @param min The lower bound
/// @param max The upper bound
/// @return true if the value is in the range, false otherwise
bool ft_inrange(int value, int min, int max);
#endif