Added memorybook to parsing and cleaned most of the files
This commit is contained in:
@@ -1,3 +1,15 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* init_game.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: pblagoje <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/05/04 13:58:13 by pblagoje #+# #+# */
|
||||
/* Updated: 2022/05/04 13:59:14 by pblagoje ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "cube3d.h"
|
||||
|
||||
static void init_img(t_img *img, void *mlx_ptr, t_win *win)
|
||||
@@ -16,12 +28,10 @@ static void init_raycast(t_rcast *rcast)
|
||||
rcast->screen_dist = dist;
|
||||
rcast->screen_width = SCREEN_WIDTH;
|
||||
rcast->screen_height = SCREEN_HEIGHT;
|
||||
// screen size
|
||||
rcast->screen_size.start.x = -SCREEN_WIDTH / 2;
|
||||
rcast->screen_size.start.y = -dist;
|
||||
rcast->screen_size.end.x = SCREEN_WIDTH / 2;
|
||||
rcast->screen_size.end.y = -dist;
|
||||
// first ray
|
||||
rcast->ray.start.x = 0;
|
||||
rcast->ray.start.y = 0;
|
||||
rcast->ray.end.x = -SCREEN_WIDTH / 2;
|
||||
@@ -30,12 +40,10 @@ static void init_raycast(t_rcast *rcast)
|
||||
|
||||
static void init_plr(t_plr *plr, t_map *map)
|
||||
{
|
||||
// player first position
|
||||
plr->exact.x = map->plr_x * CELL + CELL / 2;
|
||||
plr->exact.y = map->plr_y * CELL + CELL / 2;
|
||||
plr->pos.x = plr->exact.x;
|
||||
plr->pos.y = plr->exact.y;
|
||||
// rotation
|
||||
plr->deg = PLR_ROT;
|
||||
plr->rot = 0;
|
||||
plr->cosi = 0;
|
||||
@@ -52,33 +60,16 @@ static void init_plr(t_plr *plr, t_map *map)
|
||||
|
||||
void init_game(t_game *game)
|
||||
{
|
||||
// plr
|
||||
init_plr(&(game->plr), &(game->map));
|
||||
// init connexion to server
|
||||
game->mlx_ptr = mlx_init();
|
||||
mb_add(game->mlx_ptr);
|
||||
|
||||
// tmp draw map
|
||||
// game->map_win.size_x = game->map.size_x * CELL;
|
||||
// game->map_win.size_y = game->map.size_y * CELL + SCREEN_HEIGHT;
|
||||
// game->map_win.ptr = mlx_new_window(game->mlx_ptr, game->map_win.size_x, game->map_win.size_y, "map");
|
||||
// init_img(&(game->map_img), game->mlx_ptr, &(game->map_win));
|
||||
// // ray
|
||||
// game->ray_highlight = -1;
|
||||
// game->ray_activ = 0;
|
||||
// tmp end
|
||||
|
||||
// create window
|
||||
game->win.size_x = SCREEN_WIDTH;
|
||||
game->win.size_y = SCREEN_HEIGHT;
|
||||
game->win.ptr = mlx_new_window(game->mlx_ptr, game->win.size_x, game->win.size_y, "cub3d");
|
||||
// create img
|
||||
game->win.ptr = mlx_new_window(game->mlx_ptr, game->win.size_x, \
|
||||
game->win.size_y, "cub3d");
|
||||
init_img(&(game->img), game->mlx_ptr, &game->win);
|
||||
// create textures img
|
||||
init_txtr(&game->txt, game->mlx_ptr);
|
||||
// k(ey)_hook is the array containing the values of key press events
|
||||
ft_bzero(&game->k_hook, sizeof(game->k_hook));
|
||||
// raycasting
|
||||
init_raycast(&(game->rcast));
|
||||
game->rcast.cell = game->map.cell;
|
||||
}
|
||||
|
||||
@@ -1,3 +1,15 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* init_struct.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: pblagoje <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/05/04 13:57:22 by pblagoje #+# #+# */
|
||||
/* Updated: 2022/05/04 13:57:28 by pblagoje ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "cube3d.h"
|
||||
|
||||
static void init_null_mlx_ptr(t_game *game)
|
||||
@@ -35,11 +47,8 @@ t_game *init_struct(void)
|
||||
t_game *game;
|
||||
|
||||
game = mb_alloc(sizeof(t_game));
|
||||
// map
|
||||
init_map(&(game->map));
|
||||
// init textures and floor/ceiling colors
|
||||
init_txt_null(&(game->txt));
|
||||
// put all mlx allocated pointer to null
|
||||
init_null_mlx_ptr(game);
|
||||
return (game);
|
||||
}
|
||||
|
||||
@@ -1,3 +1,15 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* init_textures.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: pblagoje <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/05/04 13:57:11 by pblagoje #+# #+# */
|
||||
/* Updated: 2022/05/04 13:57:13 by pblagoje ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "cube3d.h"
|
||||
|
||||
static void init_txtr_img(t_img *img, void *mlx_ptr, char *path)
|
||||
|
||||
Reference in New Issue
Block a user