1
0

」 feat(Raycasting): Now working 🎉

This commit is contained in:
2024-11-02 16:08:39 +01:00
parent cec486ad81
commit 2df57b2f15
9 changed files with 51 additions and 58 deletions

View File

@ -6,23 +6,22 @@
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/10/28 13:04:36 by adjoly #+# #+# */
/* Updated: 2024/10/29 14:15:59 by adjoly ### ########.fr */
/* Updated: 2024/11/02 15:57:19 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
# ifndef DDA_H
#ifndef DDA_H
# define DDA_H
# include <math.h>
# include "game.h"
#include "game/vectwo.h"
# include "game/vectwo.h"
typedef struct s_dda
{
bool h;
int i;
bool s;
t_vec2 map;
t_vec2 vert;
t_vec2 hori;

View File

@ -6,7 +6,7 @@
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/09/11 16:38:40 by adjoly #+# #+# */
/* Updated: 2024/10/29 13:56:32 by adjoly ### ########.fr */
/* Updated: 2024/11/02 15:55:39 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
@ -53,7 +53,6 @@ typedef struct s_render
void *texture[4];
} t_render;
/**
* @brief This function is used to handle keypress
*
@ -64,7 +63,6 @@ typedef struct s_render
*/
int key_hook(int key, void *param);
/**
* @brief This function is here to change the direction of the player
* by setting the t_player->direction and check overflow to be
@ -77,7 +75,6 @@ int key_hook(int key, void *param);
*/
void change_direction(float speed, bool clockwise, t_player *player);
/**
* @brief Render a cub3d frame by executing a dda on every ray and
* putting the pixel on the window

View File

@ -6,11 +6,11 @@
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/10/04 14:06:39 by adjoly #+# #+# */
/* Updated: 2024/11/02 14:15:03 by adjoly ### ########.fr */
/* Updated: 2024/11/02 15:55:02 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef SETTINGS_H
#ifndef SETTINGS_H
# define SETTINGS_H
// Key code
@ -24,8 +24,8 @@
# define WINDOW_W 1600
# define WINDOW_H 900
# define PLAYER_ROT_SPEED (2 * M_PI) / 128
# define PLAYER_SPEED 0.5
# define PLAYER_ROT_SPEED 0.034906585039887
# define PLAYER_SPEED 1.5
# define FOV 70
# define CHUNK_SIZE 64

View File

@ -6,14 +6,14 @@
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/10/29 10:07:24 by adjoly #+# #+# */
/* Updated: 2024/10/29 10:08:04 by adjoly ### ########.fr */
/* Updated: 2024/11/02 15:54:32 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef UTILS_MATH_H
# define UTILS_MATH_H
#include <math.h>
# include <math.h>
void fix_ang(float *ang);

View File

@ -6,13 +6,15 @@
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/10/28 13:32:14 by adjoly #+# #+# */
/* Updated: 2024/10/28 14:24:56 by adjoly ### ########.fr */
/* Updated: 2024/11/02 15:51:49 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef VECTWO_H
# define VECTWO_H
# include <stdint.h>
typedef struct s_vec2
{
float x;
@ -35,4 +37,9 @@ void vec2_add(t_vec2 *first, t_vec2 second);
* @brief Just substract second to first
*/
void vec2_sub(t_vec2 *first, t_vec2 second);
/**
* @brief Multiply a vec2 by a number n and returns it
*/
t_vec2 vec2_mul_ret(t_vec2 vec, float n);
#endif