fix: render *

fix:
- fix texture for each direction (north texture is in north etc)
- fix mirror textures (the left of each texture is at its left)
- fix dimensions (walls are 1x1 for any window dimensions or FOV)
- optimize render()

dev:
- add testmaps/good_directions_test.cub
- add textures/test/*.xpm
This commit is contained in:
mcolonna 2024-11-12 13:07:09 +01:00
parent 184c8a60af
commit 6007f27510
14 changed files with 488 additions and 164 deletions

View file

@ -3,10 +3,10 @@
/* ::: :::::::: */
/* const.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mc <mc@student.42.fr> +#+ +:+ +#+ */
/* By: mcolonna <mcolonna@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/10/31 17:00:59 by mc #+# #+# */
/* Updated: 2024/11/07 19:26:53 by mc ### ########.fr */
/* Updated: 2024/11/12 17:56:05 by mcolonna ### ########.fr */
/* */
/* ************************************************************************** */

View file

@ -3,10 +3,10 @@
/* ::: :::::::: */
/* include.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mc <mc@student.42.fr> +#+ +:+ +#+ */
/* By: mcolonna <mcolonna@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/10/31 16:22:09 by mc #+# #+# */
/* Updated: 2024/10/31 18:03:26 by mc ### ########.fr */
/* Updated: 2024/11/12 17:41:11 by mcolonna ### ########.fr */
/* */
/* ************************************************************************** */
@ -23,6 +23,7 @@
# include <stdio.h>
# include <stdlib.h>
# include <string.h>
# include <sys/types.h>
# include <unistd.h>
# include <X11/keysym.h>
# include <X11/X.h>

View file

@ -3,10 +3,10 @@
/* ::: :::::::: */
/* map.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mc <mc@student.42.fr> +#+ +:+ +#+ */
/* By: mcolonna <mcolonna@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/10/01 13:59:04 by mcolonna #+# #+# */
/* Updated: 2024/11/06 19:24:03 by mc ### ########.fr */
/* Updated: 2024/11/12 15:10:07 by mcolonna ### ########.fr */
/* */
/* ************************************************************************** */
@ -82,7 +82,7 @@ typedef struct s_player
{
// pos player on map (cases)
t_point_double pos;
// player rotation (rad)
// player rotation (rad) (0 rad is -y / pi/2 rad is +x)
double rot;
} t_player;

View file

@ -6,7 +6,7 @@
/* By: mcolonna <mcolonna@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/10/31 17:13:20 by mc #+# #+# */
/* Updated: 2024/11/04 13:47:47 by mcolonna ### ########.fr */
/* Updated: 2024/11/12 12:24:02 by mcolonna ### ########.fr */
/* */
/* ************************************************************************** */
@ -16,7 +16,6 @@
# include "include.h"
# include "utils.h"
# include "temp.h"
# include "const.h"
# include "global.h"

View file

@ -1,47 +0,0 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* temp.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mc <mc@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/10/31 17:04:08 by mc #+# #+# */
/* Updated: 2024/11/07 19:07:25 by mc ### ########.fr */
/* */
/* ************************************************************************** */
// DEBUG remove temp.h
#ifndef TEMP_H
# define TEMP_H
# include "include.h"
# include "utils.h"
# define TEX_WIDTH 64
# define TEX_HEIGHT 64
typedef struct s_tex
{
void *textures[4];
void *current_tex;
int tex_height;
int tex_width;
int tex_dir;
int tex_x;
int tex_y;
int bpp;
int size_line;
int endian;
} t_tex;
typedef struct s_ray
{
// pos player on map (cases)
t_point_double dir;
bool side;
double wallx;
} t_ray;
#endif

View file

@ -3,10 +3,10 @@
/* ::: :::::::: */
/* utils.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mc <mc@student.42.fr> +#+ +:+ +#+ */
/* By: mcolonna <mcolonna@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/10/15 16:56:47 by mcolonna #+# #+# */
/* Updated: 2024/11/07 19:07:03 by mc ### ########.fr */
/* Updated: 2024/11/12 17:01:35 by mcolonna ### ########.fr */
/* */
/* ************************************************************************** */
@ -61,7 +61,7 @@ void timedloop(void (*f)(void));
uint32_t *get_data_addr(void *img_ptr);
/// @brief Create a vector according to the angle with a specific norm.
/// (0 rad returns (0;-1) / pi/2 rad returns (1;0))
/// (0 rad is -y / pi/2 rad is +x)
///
/// @param vec This will be set to the result.
/// @param angle Angle to use in radians.