docs, clean, several things... *
- add docs - remove unused things - redo modifications i accidentally erased from spacetime
This commit is contained in:
parent
47a6b6df35
commit
26621c72c6
25 changed files with 199 additions and 140 deletions
|
|
@ -6,7 +6,7 @@
|
|||
/* By: mc <mc@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/10/31 17:00:59 by mc #+# #+# */
|
||||
/* Updated: 2024/10/31 17:06:00 by mc ### ########.fr */
|
||||
/* Updated: 2024/10/31 18:15:13 by mc ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -15,17 +15,18 @@
|
|||
|
||||
# include "include.h"
|
||||
|
||||
# define MAP_WIDTH 24 // cases (TODO test)
|
||||
# define MAP_HEIGHT 24 // cases (TODO test)
|
||||
# define MOVE_SPEED 0.05 // cases
|
||||
# define PI 3.1415926535
|
||||
# define ROT_SPEED_DIVIDE_PI 64 // pi/n rad
|
||||
# define COLOR_WALL 0xFF0000 // 0xRRGGBB
|
||||
# define COLOR_CEILING 0x29f8ff // 0xRRGGBB
|
||||
# define COLOR_FLOOR 0xFF985C // 0xRRGGBB
|
||||
# define SCREEN_WIDTH 640 // px
|
||||
# define SCREEN_HEIGHT 480 // px
|
||||
# define FOV 0.66 // ? TODO unit
|
||||
# define HITBOX 0.25 // cases. should be more than MOVE_SPEED
|
||||
# define PI 3.1415926535 // it's just pi
|
||||
|
||||
# define MOVE_SPEED 0.05 // Player oves by N cases by tick
|
||||
# define ROT_SPEED_DIVIDE_PI 64 // Player turns by pi/N rad by tick
|
||||
# define HITBOX 0.25 // Hitbox of N cases around player.
|
||||
|
||||
# define COLOR_CEILING 0x29f8ff // TODO get from cub file
|
||||
# define COLOR_FLOOR 0xFF985C // TODO get from cub file
|
||||
|
||||
# define SCREEN_WIDTH 640 // Width of the window
|
||||
# define SCREEN_HEIGHT 480 // Height of the window
|
||||
|
||||
# define FOV 0.66 // ? TODO no idea
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: mc <mc@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/10/31 17:06:31 by mc #+# #+# */
|
||||
/* Updated: 2024/10/31 17:29:00 by mc ### ########.fr */
|
||||
/* Updated: 2024/10/31 18:11:08 by mc ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -17,9 +17,13 @@
|
|||
|
||||
# include "map.h"
|
||||
|
||||
/// @brief mlx connection identifier
|
||||
extern void *g_mlx;
|
||||
|
||||
/// @brief Identifier to the opened window
|
||||
extern void *g_win;
|
||||
extern t_player g_player;
|
||||
|
||||
/// @brief Current map
|
||||
extern t_map g_map;
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: mc <mc@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/10/17 14:43:09 by mcolonna #+# #+# */
|
||||
/* Updated: 2024/10/31 16:24:16 by mc ### ########.fr */
|
||||
/* Updated: 2024/11/01 20:59:28 by mc ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -15,8 +15,7 @@
|
|||
|
||||
# include "include.h"
|
||||
|
||||
/// @brief Modified by the input of the user. A value becomes true
|
||||
/// when the user presses the corresponding key.
|
||||
/// @brief For g_input_actions
|
||||
typedef struct s_input_actions
|
||||
{
|
||||
bool left;
|
||||
|
|
@ -26,10 +25,23 @@ typedef struct s_input_actions
|
|||
bool quit;
|
||||
} t_input_actions;
|
||||
|
||||
/// @brief Modified by the input of the user. A value becomes true
|
||||
/// when the user presses the corresponding key.
|
||||
extern t_input_actions g_input_actions;
|
||||
|
||||
int keypress(int keycode);
|
||||
int keyrelease(int keycode);
|
||||
/// @brief To call when a specific key is newly pressed.
|
||||
///
|
||||
/// @param keycode Key pressed.
|
||||
/// @return Unused.
|
||||
int hook_keypress(int keycode);
|
||||
|
||||
/// @brief To call when a specific key is released.
|
||||
///
|
||||
/// @param keycode Key released.
|
||||
/// @return Unused.
|
||||
int hook_keyrelease(int keycode);
|
||||
|
||||
/// @brief To call at the start of the program.
|
||||
void input_init(void);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: mc <mc@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/10/01 13:59:04 by mcolonna #+# #+# */
|
||||
/* Updated: 2024/10/31 17:55:39 by mc ### ########.fr */
|
||||
/* Updated: 2024/11/06 19:24:03 by mc ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
# include "utils.h"
|
||||
|
||||
/// @brief The type of a case.
|
||||
/// @brief The type of a case.
|
||||
typedef enum e_map_wall
|
||||
{
|
||||
/// @brief Empty case, for '0' and ' '.
|
||||
|
|
@ -32,16 +32,19 @@ typedef struct s_object
|
|||
/// @brief Function called when creating the object.
|
||||
///
|
||||
/// @param data Address of the s_object.data pointer.
|
||||
/// @param pos Start position of the object.
|
||||
void (*init)(void **data, t_point_int pos);
|
||||
|
||||
/// @brief Function called when destroying the object (to avoid leaks).
|
||||
///
|
||||
/// @param data Address of the s_object.data pointer.
|
||||
/// @param pos Start position of the object.
|
||||
void (*destroy)(void **data, t_point_int pos);
|
||||
|
||||
/// @brief Function called each tick.
|
||||
///
|
||||
/// @param data Address of the s_object.data pointer.
|
||||
/// @param pos Start position of the object.
|
||||
void (*tick)(void **data, t_point_int pos);
|
||||
|
||||
/// @brief Pointer the object can use to save data.
|
||||
|
|
@ -83,6 +86,21 @@ typedef struct s_player
|
|||
double rot;
|
||||
} t_player;
|
||||
|
||||
typedef enum e_direction
|
||||
{
|
||||
NORTH,
|
||||
SOUTH,
|
||||
EAST,
|
||||
WEST,
|
||||
} t_direction;
|
||||
|
||||
typedef struct s_texture
|
||||
{
|
||||
int width;
|
||||
int height;
|
||||
void *image;
|
||||
} t_texture;
|
||||
|
||||
/// @brief Represents a map.
|
||||
typedef struct s_map
|
||||
{
|
||||
|
|
@ -92,17 +110,11 @@ typedef struct s_map
|
|||
/// @brief Color of the ceiling.
|
||||
t_color color_ceiling;
|
||||
|
||||
/// @brief Path to the image file for the wall face north.
|
||||
const char *texture_north;
|
||||
/// @brief File path for each texture. Index is t_direction.
|
||||
const char *texture_srcs[4];
|
||||
|
||||
/// @brief Path to the image file for the wall face south.
|
||||
const char *texture_south;
|
||||
|
||||
/// @brief Path to the image file for the wall face west.
|
||||
const char *texture_west;
|
||||
|
||||
/// @brief Path to the image file for the wall face east.
|
||||
const char *texture_east;
|
||||
/// @brief All textures. Index is t_direction.
|
||||
t_texture textures[4];
|
||||
|
||||
/// @brief Width of the map.
|
||||
unsigned int width;
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: mc <mc@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/10/31 16:59:27 by mc #+# #+# */
|
||||
/* Updated: 2024/10/31 16:59:48 by mc ### ########.fr */
|
||||
/* Updated: 2024/11/01 21:05:51 by mc ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -15,6 +15,7 @@
|
|||
|
||||
# include "include.h"
|
||||
|
||||
/// @brief Move the player according to the user input.
|
||||
void move(void);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: mc <mc@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/10/15 17:31:35 by mcolonna #+# #+# */
|
||||
/* Updated: 2024/10/31 17:30:01 by mc ### ########.fr */
|
||||
/* Updated: 2024/11/01 20:41:30 by mc ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -17,9 +17,16 @@
|
|||
|
||||
# include "utils.h"
|
||||
|
||||
/// @brief Create a player facing north (to use with t_object.init).
|
||||
void init_player_n(void **data, t_point_int pos);
|
||||
|
||||
/// @brief Create a player facing south (to use with t_object.init).
|
||||
void init_player_s(void **data, t_point_int pos);
|
||||
|
||||
/// @brief Create a player facing west (to use with t_object.init).
|
||||
void init_player_w(void **data, t_point_int pos);
|
||||
|
||||
/// @brief Create a player facing east (to use with t_object.init).
|
||||
void init_player_e(void **data, t_point_int pos);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -3,10 +3,10 @@
|
|||
/* ::: :::::::: */
|
||||
/* render.h :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: mc <mc@student.42.fr> +#+ +:+ +#+ */
|
||||
/* By: mcolonna <mcolonna@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/10/31 17:13:20 by mc #+# #+# */
|
||||
/* Updated: 2024/10/31 17:27:33 by mc ### ########.fr */
|
||||
/* Updated: 2024/11/04 13:47:47 by mcolonna ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -17,7 +17,13 @@
|
|||
|
||||
# include "utils.h"
|
||||
# include "temp.h"
|
||||
# include "const.h"
|
||||
# include "global.h"
|
||||
|
||||
int render(u_int32_t *img_data, t_tex *tex);
|
||||
/// @brief Draw the camera image using raycasting.
|
||||
///
|
||||
/// @param img_data Data addr of the image to draw on.
|
||||
/// @return Unused.
|
||||
int render(u_int32_t *img_data);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: mc <mc@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/10/15 16:56:47 by mcolonna #+# #+# */
|
||||
/* Updated: 2024/10/31 17:15:31 by mc ### ########.fr */
|
||||
/* Updated: 2024/11/01 20:55:00 by mc ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -17,12 +17,14 @@
|
|||
|
||||
typedef uint32_t u_int32_t;
|
||||
|
||||
/// @brief Represents a point of double type.
|
||||
typedef struct s_point_double
|
||||
{
|
||||
double x;
|
||||
double y;
|
||||
} t_point_double;
|
||||
|
||||
/// @brief Represents a point of int type.
|
||||
typedef struct s_point_int
|
||||
{
|
||||
int x;
|
||||
|
|
@ -60,6 +62,12 @@ void timedloop(void (*f)(void));
|
|||
/// @return Address to the data, or NULL if error.
|
||||
u_int32_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))
|
||||
///
|
||||
/// @param vec This will be set to the result.
|
||||
/// @param angle Angle to use in radians.
|
||||
/// @param norm Norm the vector must have.
|
||||
void vector_from_rotation(t_point_double *vec, double angle, double norm);
|
||||
|
||||
/// @brief Size of buffer used in read_all_text().
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue