Skip to content

Commit

Permalink
no leaks, normed, finished cool
Browse files Browse the repository at this point in the history
  • Loading branch information
Mathis ROLY committed Apr 4, 2022
1 parent de0c1eb commit eab193f
Show file tree
Hide file tree
Showing 21 changed files with 200 additions and 176 deletions.
83 changes: 43 additions & 40 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,46 +1,47 @@
SRC = main.c \
get_next_line.c get_next_line_u.c \
parse_map.c \
exit.c \
utils_str.c utils_free.c \
SRC = main.c \
get_next_line.c get_next_line_u.c \
parse_map.c \
exit.c \
utils_str.c utils_free.c \
check_cub.c check_cub2.c check_cub3.c \
check_handv.c \
check_handv.c \
count_island.c count_island_utils.c \
ray_casting.c ray_casting_utils.c \
draw.c \
open_texture.c \
texturing.c \
init_player.c \
utils_mlx.c \
controls.c controls_wasd.c \
ft_split.c \
ft_convert_base.c ft_convert_base2.c\


SRC_BONUS = main.c \
get_next_line.c get_next_line_u.c \
parse_map.c \
exit.c \
utils_str.c utils_free.c \
ray_casting.c ray_casting_utils.c \
draw.c \
open_texture.c \
texturing.c \
init_player.c \
utils_mlx.c \
controls.c controls_wasd.c \
ft_split.c \
ft_convert_base.c ft_convert_base2.c \


SRC_BONUS = main.c \
get_next_line.c get_next_line_u.c \
parse_map.c \
exit.c \
utils_str.c utils_free.c \
check_cub.c check_cub2.c check_cub3.c \
check_handv.c \
check_handv.c \
count_island.c count_island_utils.c \
ray_casting.c ray_casting_utils.c \
draw.c \
open_texture.c \
texturing.c \
init_player.c \
utils_mlx.c \
controls.c controls_wasd.c \
ft_split.c \
ft_convert_base.c ft_convert_base2.c \
mouse.c \
mini_map.c \
ray_casting.c ray_casting_utils.c \
draw.c \
open_texture.c \
texturing.c \
init_player.c \
utils_mlx.c \
controls.c controls_wasd.c \
ft_split.c \
ft_convert_base.c ft_convert_base2.c \
mouse.c \
mini_map.c \
background.c \


NAME = cub3d
NAME = cub3D

NAME_BONUS = cub3d_bo
NAME_BONUS = cub3D_bo

UNAME := $(shell uname)

Expand All @@ -61,7 +62,7 @@ BONUS_MLX_DIR = $(addprefix cub3d_bonus/, $(MLX_DIR))
MAND_MLX = $(addprefix cub3d_mand/, $(MLX))
BONUS_MLX = $(addprefix cub3d_bonus/, $(MLX))

CFLAGS = -Wall -Wextra -Werror -g -fsanitize=address
CFLAGS = -Wall -Wextra -Werror -g #-fsanitize=address

OBJ_DIR = cub3d_mand/obj
SRC_DIR = cub3d_mand/src
Expand Down Expand Up @@ -109,15 +110,17 @@ clean:
fclean: clean
@rm -rf $(NAME)

clean_bonus:
cleanb:
@rm -rf $(OBJ_DIR_BONUS)

fclean_bonus: clean_bonus
fcleanb: cleanb
@rm -rf $(NAME_BONUS)

ffclean: fclean fcleanb

re: fclean all

re_bonus: fclean_bonus bonus
reb: fcleanb bonus

.PHONY: all, clean, fclean, re, bonus

Expand Down
6 changes: 4 additions & 2 deletions cub3d_bonus/inc/function.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* By: maroly <maroly@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/03/15 18:48:21 by hkovac #+# #+# */
/* Updated: 2022/03/31 19:24:48 by maroly ### ########.fr */
/* Updated: 2022/04/04 12:26:31 by maroly ### ########.fr */
/* */
/* ************************************************************************** */

Expand Down Expand Up @@ -79,7 +79,6 @@ void init_dir(t_gbl *gbl, t_rc *rc);
/*utils_mlx.c*/
void re_win(t_gbl *gbl);
int destroy_window(t_gbl *gbl);
void reframe(t_gbl *gbl);
/*controls.c*/
int controls(int keycode, t_gbl *gbl);
void head_up(t_gbl *gbl, int mult);
Expand All @@ -104,4 +103,7 @@ int mouse(int x, int y, t_gbl *gbl);
int mouse_pressed(int button, int x, int y, t_gbl *gbl);
/*mini_map.c*/
void print_map(t_gbl *gbl);
/*background.c*/
void floor_sky(t_gbl *gbl);

#endif
10 changes: 5 additions & 5 deletions cub3d_bonus/inc/include.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* By: maroly <maroly@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/03/15 18:36:24 by hkovac #+# #+# */
/* Updated: 2022/04/02 14:10:56 by maroly ### ########.fr */
/* Updated: 2022/04/04 11:05:29 by maroly ### ########.fr */
/* */
/* ************************************************************************** */

Expand All @@ -32,7 +32,7 @@
# define PI 3.1415926

//MacOS
# define UP 13
/*# define UP 13
# define DOWN 1
# define LEFT 0
# define RIGHT 2
Expand All @@ -41,10 +41,10 @@
# define ESC 53
# define SHIFT 257
# define ARROW_UP 126
# define ARROW_DOWN 125
# define ARROW_DOWN 125*/

//LINUX
/*# define UP 119
# define UP 119
# define DOWN 115
# define LEFT 97
# define RIGHT 100
Expand All @@ -53,7 +53,7 @@
# define ESC 65307
# define SHIFT 65505
# define ARROW_UP 65362
# define ARROW_DOWN 65364*/
# define ARROW_DOWN 65364
# include <stdlib.h>
# include <sys/types.h>
# include <sys/uio.h>
Expand Down
24 changes: 24 additions & 0 deletions cub3d_bonus/maps/carre.cub
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,34 @@ SO ./WallPack/Blue5.xpm
EA ./WallPack/Blue5.xpm
WE ./WallPack/Blue5.xpm
DO ./WallPack/Blue1.xpm



















CL ./WallPack/cloud.xpm

F 33,33,33
C 89,1,238





1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001
10000000011111111111000111111111001000000000011111111111111111111111111111111111111111111111111111111111111111111111111111111
Expand Down
58 changes: 58 additions & 0 deletions cub3d_bonus/src/background.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* background.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maroly <maroly@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/04/04 11:52:01 by maroly #+# #+# */
/* Updated: 2022/04/04 11:52:16 by maroly ### ########.fr */
/* */
/* ************************************************************************** */

#include <include.h>

void print_cloud(t_gbl *gbl)
{
int x;
int y;
char *tmp;
unsigned int color;

y = -1;
while (++y < gbl->tex_tab[CL]->texheight)
{
x = -1;
while (++x < gbl->tex_tab[CL]->texwidth)
{
tmp = gbl->tex_tab[CL]->addr + (y * gbl->tex_tab[CL]->line_length
+ x * (gbl->tex_tab[CL]->bpp / 8));
color = *(unsigned int *)tmp;
if (color != 4278190080 && color != 15599110)
put_pixel_image(gbl->mlx, x + gbl->posxcloud,
50 + y + gbl->posycloud, color);
}
}
gbl->posxcloud += 0.15;
}

void floor_sky(t_gbl *gbl)
{
int x;
int y;

y = -1;
while (++y < HEIGHT)
{
x = -1;
if (y < HEIGHT * gbl->horizon)
while (++x < WIDTH)
put_pixel_image(gbl->mlx, x, y, gbl->sky);
else
{
while (++x < WIDTH)
put_pixel_image(gbl->mlx, x, y, gbl->floor);
}
}
print_cloud(gbl);
}
6 changes: 3 additions & 3 deletions cub3d_bonus/src/check_handv.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* By: maroly <maroly@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/03/31 19:22:57 by maroly #+# #+# */
/* Updated: 2022/04/02 21:25:31 by maroly ### ########.fr */
/* Updated: 2022/04/04 11:49:57 by maroly ### ########.fr */
/* */
/* ************************************************************************** */

Expand Down Expand Up @@ -55,7 +55,7 @@ int check_map_horizontal(t_gbl *gbl)

int check_map_vertical2(t_gbl *gbl, int *j)
{
int i;
int i;

i = 0;
while (gbl->map[i])
Expand All @@ -64,7 +64,7 @@ int check_map_vertical2(t_gbl *gbl, int *j)
|| gbl->map[i][*j] == ' '))
i++;
if (!gbl->map[i])
break;
break ;
if (is_j_in(gbl->map[i], *j) == 0 && gbl->map[i][*j] != '1')
return (1);
while (gbl->map[i] && is_j_in(gbl->map[i], *j) == 0
Expand Down
12 changes: 6 additions & 6 deletions cub3d_bonus/src/controls.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* By: maroly <maroly@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/03/29 10:05:14 by hkovac #+# #+# */
/* Updated: 2022/04/02 15:03:06 by maroly ### ########.fr */
/* Updated: 2022/04/04 12:24:05 by maroly ### ########.fr */
/* */
/* ************************************************************************** */

Expand All @@ -16,14 +16,14 @@ void head_up(t_gbl *gbl, int mult)
{
gbl->head += 10 * mult;
gbl->horizon += 0.0156 * mult;
gbl->posycloud += 10;
gbl->posycloud += 10 * mult;
}

void head_down(t_gbl *gbl, int mult)
{
gbl->head -= 10 * mult;
gbl->horizon -= 0.0156 * mult;
gbl->posycloud -= 10;
gbl->posycloud -= 10 * mult;
}

void arrow_left(t_gbl *gbl, int mult)
Expand All @@ -41,7 +41,7 @@ void arrow_left(t_gbl *gbl, int mult)
- gbl->rc->planey * sin(-0.03 * mult);
gbl->rc->planey = oldplanex * sin(-0.03 * mult)
+ gbl->rc->planey * cos(-0.03 * mult);
gbl->posxcloud += 21;
gbl->posxcloud += 21 * mult;
}

void arrow_right(t_gbl *gbl, int mult)
Expand All @@ -59,7 +59,7 @@ void arrow_right(t_gbl *gbl, int mult)
- gbl->rc->planey * sin(0.03 * mult);
gbl->rc->planey = oldplanex * sin(0.03 * mult)
+ gbl->rc->planey * cos(0.03 * mult);
gbl->posxcloud -= 21;
gbl->posxcloud -= 21 * mult;
}

int controls(int keycode, t_gbl *gbl)
Expand All @@ -84,6 +84,6 @@ int controls(int keycode, t_gbl *gbl)
head_up(gbl, 1);
else if (keycode == ARROW_DOWN)
head_down(gbl, 1);
reframe(gbl);
re_win(gbl);
return (1);
}
4 changes: 2 additions & 2 deletions cub3d_bonus/src/draw.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* By: maroly <maroly@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/03/23 16:47:25 by maroly #+# #+# */
/* Updated: 2022/03/31 18:25:23 by maroly ### ########.fr */
/* Updated: 2022/04/04 11:49:13 by maroly ### ########.fr */
/* */
/* ************************************************************************** */

Expand All @@ -17,7 +17,7 @@ void init_mlx(t_mlx *mlx, int x, int y)
mlx->x_size = x;
mlx->y_size = y;
mlx->mlx = mlx_init();
mlx->mlx_win = mlx_new_window(mlx->mlx, x, y, "Cub3d");
mlx->mlx_win = mlx_new_window(mlx->mlx, x, y, "cub3D");
mlx->img = mlx_new_image(mlx->mlx, x, y);
mlx->addr = mlx_get_data_addr(mlx->img, &mlx->bpp,
&mlx->line_length, &mlx->endian);
Expand Down
Loading

0 comments on commit eab193f

Please sign in to comment.