This commit is contained in:
Ladebeze66 2024-01-17 21:53:29 +01:00
parent 5ec8268935
commit 05f1323377
65 changed files with 144 additions and 15 deletions

View File

@ -0,0 +1,18 @@
{
"configurations": [
{
"name": "linux-gcc-x64",
"includePath": [
"${workspaceFolder}/**"
],
"compilerPath": "/usr/bin/gcc",
"cStandard": "${default}",
"cppStandard": "${default}",
"intelliSenseMode": "linux-gcc-x64",
"compilerArgs": [
""
]
}
],
"version": 4
}

24
versionmod/.vscode/launch.json vendored Normal file
View File

@ -0,0 +1,24 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "C/C++ Runner: Debug Session",
"type": "cppdbg",
"request": "launch",
"args": [],
"stopAtEntry": false,
"externalConsole": false,
"cwd": "/home/fgras-ca/Bureau/Nouveau dossier/cub3D/versionmod",
"program": "/home/fgras-ca/Bureau/Nouveau dossier/cub3D/versionmod/build/Debug/outDebug",
"MIMode": "gdb",
"miDebuggerPath": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}

59
versionmod/.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,59 @@
{
"C_Cpp_Runner.cCompilerPath": "gcc",
"C_Cpp_Runner.cppCompilerPath": "g++",
"C_Cpp_Runner.debuggerPath": "gdb",
"C_Cpp_Runner.cStandard": "",
"C_Cpp_Runner.cppStandard": "",
"C_Cpp_Runner.msvcBatchPath": "C:/Program Files/Microsoft Visual Studio/VR_NR/Community/VC/Auxiliary/Build/vcvarsall.bat",
"C_Cpp_Runner.useMsvc": false,
"C_Cpp_Runner.warnings": [
"-Wall",
"-Wextra",
"-Wpedantic",
"-Wshadow",
"-Wformat=2",
"-Wcast-align",
"-Wconversion",
"-Wsign-conversion",
"-Wnull-dereference"
],
"C_Cpp_Runner.msvcWarnings": [
"/W4",
"/permissive-",
"/w14242",
"/w14287",
"/w14296",
"/w14311",
"/w14826",
"/w44062",
"/w44242",
"/w14905",
"/w14906",
"/w14263",
"/w44265",
"/w14928"
],
"C_Cpp_Runner.enableWarnings": true,
"C_Cpp_Runner.warningsAsError": false,
"C_Cpp_Runner.compilerArgs": [],
"C_Cpp_Runner.linkerArgs": [],
"C_Cpp_Runner.includePaths": [],
"C_Cpp_Runner.includeSearch": [
"*",
"**/*"
],
"C_Cpp_Runner.excludeSearch": [
"**/build",
"**/build/**",
"**/.*",
"**/.*/**",
"**/.vscode",
"**/.vscode/**"
],
"C_Cpp_Runner.useAddressSanitizer": false,
"C_Cpp_Runner.useUndefinedSanitizer": false,
"C_Cpp_Runner.useLeakSanitizer": false,
"C_Cpp_Runner.showCompilationTime": false,
"C_Cpp_Runner.useLinkTimeOptimization": false,
"C_Cpp_Runner.msvcSecureNoWarnings": false
}

Binary file not shown.

View File

@ -6,7 +6,7 @@
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/01/12 17:49:42 by fgras-ca #+# #+# */
/* Updated: 2024/01/15 18:44:32 by fgras-ca ### ########.fr */
/* Updated: 2024/01/17 21:47:17 by fgras-ca ### ########.fr */
/* */
/* ************************************************************************** */

Binary file not shown.

View File

@ -6,7 +6,7 @@
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/01/14 20:30:59 by fgras-ca #+# #+# */
/* Updated: 2024/01/16 17:36:23 by fgras-ca ### ########.fr */
/* Updated: 2024/01/17 21:45:36 by fgras-ca ### ########.fr */
/* */
/* ************************************************************************** */
@ -16,8 +16,8 @@ void load_texture(t_structure_main *w, char *file_path, void **texture_ptr)
{
int width;
int height;
//printf("load texture %s\n", file_path);
//w->s_win.mlx = mlx_init();
printf("file path %s\n", file_path);
width = 0;
height = 0;
*texture_ptr = mlx_xpm_file_to_image(w->s_win.mlx,
@ -29,15 +29,24 @@ void load_texture(t_structure_main *w, char *file_path, void **texture_ptr)
}
w->s_img.texture_width = width;
w->s_img.texture_height = height;
printf("height %d\n", height);
printf("width %d\n", width);
}
void load_wall_textures(t_structure_main *w)
{
printf("loadtexture %s\n", w->t->north);
printf("load wall texture %s\n", w->t->north);
printf("load wall texture %s\n", w->t->south);
printf("load wall texture %s\n", w->t->east);
printf("load wall texture %s\n", w->t->west);
load_texture(w, w->t->north, (void **)&w->s_img.north_texture);
load_texture(w, w->t->south, (void **)&w->s_img.south_texture);
load_texture(w, w->t->west, (void **)&w->s_img.west_texture);
load_texture(w, w->t->east, (void **)&w->s_img.east_texture);
printf("load wall texture %s\n", w->t->north);
printf("load wall texture %s\n", w->t->south);
printf("load wall texture %s\n", w->t->east);
printf("load wall texture %s\n", w->t->west);
}
void exit_error(t_structure_main *w)

Binary file not shown.

View File

@ -6,7 +6,7 @@
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/01/12 17:39:11 by fgras-ca #+# #+# */
/* Updated: 2024/01/16 16:55:50 by fgras-ca ### ########.fr */
/* Updated: 2024/01/17 21:38:40 by fgras-ca ### ########.fr */
/* */
/* ************************************************************************** */
@ -36,6 +36,7 @@ void draw_texture_line(t_texture_params *params, float y, int textureY)
put_pixel_img(params->w, x, y, color);
x++;
}
printf("draw_texture_line: texturex = %d, textureY = %d, color = %d\n", texturex, textureY, color);
}
void draw_texture(t_texture_params *params)
@ -55,11 +56,13 @@ void draw_texture(t_texture_params *params)
texturey = textureheight - 1;
draw_texture_line(params, y, texturey);
y++;
}
}printf("draw_texture: y = %f, texturey = %d\n", y, texturey);
}
void *get_selected_texture(t_structure_main *w, WallDirection wallDir)
{
void *texture = NULL;
if (wallDir == NORTH)
return (w->t->north);
else if (wallDir == SOUTH)
@ -74,6 +77,11 @@ void *get_selected_texture(t_structure_main *w, WallDirection wallDir)
exit_error(w);
return (NULL);
}
if (texture == NULL) {
fprintf(stderr, "get_selected_texture: selected texture is NULL\n");
} else {
printf("get_selected_texture: selected texture = %p\n", texture);
}
}
t_texture_data get_texture_data(void *texture)
@ -82,6 +90,7 @@ t_texture_data get_texture_data(void *texture)
texture_data.data = mlx_get_data_addr(texture, &texture_data.bpp,
&texture_data.size_line, &texture_data.endian);
printf("get_texture_data: bpp = %d, size_line = %d, endian = %d\n", texture_data.bpp, texture_data.size_line, texture_data.endian);
return (texture_data);
}
@ -97,8 +106,10 @@ int get_texture_color(t_structure_main *w, WallDirection wallDir,
{
return (0);
}
texture_data = get_texture_data(selected_texture);
pixel_pos = (textureX + textureY * w->s_img.texture_width)
* (texture_data.bpp / 8);
printf("get_texture_color: textureX = %d, textureY = %d, pixel_pos = %d\n", textureX, textureY, pixel_pos);
return (*(int *)(texture_data.data + pixel_pos));
}

Binary file not shown.

0
versionmod/libft/Makefile Executable file → Normal file
View File

0
versionmod/libft/ft_atoi.c Executable file → Normal file
View File

0
versionmod/libft/ft_bzero.c Executable file → Normal file
View File

0
versionmod/libft/ft_calloc.c Executable file → Normal file
View File

0
versionmod/libft/ft_isalnum.c Executable file → Normal file
View File

0
versionmod/libft/ft_isalpha.c Executable file → Normal file
View File

0
versionmod/libft/ft_isascii.c Executable file → Normal file
View File

0
versionmod/libft/ft_isdigit.c Executable file → Normal file
View File

0
versionmod/libft/ft_isprint.c Executable file → Normal file
View File

0
versionmod/libft/ft_itoa.c Executable file → Normal file
View File

0
versionmod/libft/ft_lstadd_back.c Executable file → Normal file
View File

0
versionmod/libft/ft_lstadd_front.c Executable file → Normal file
View File

0
versionmod/libft/ft_lstclear.c Executable file → Normal file
View File

0
versionmod/libft/ft_lstdelone.c Executable file → Normal file
View File

0
versionmod/libft/ft_lstiter.c Executable file → Normal file
View File

0
versionmod/libft/ft_lstlast.c Executable file → Normal file
View File

0
versionmod/libft/ft_lstmap.c Executable file → Normal file
View File

0
versionmod/libft/ft_lstnew.c Executable file → Normal file
View File

0
versionmod/libft/ft_lstsize.c Executable file → Normal file
View File

0
versionmod/libft/ft_memchr.c Executable file → Normal file
View File

0
versionmod/libft/ft_memcmp.c Executable file → Normal file
View File

0
versionmod/libft/ft_memcpy.c Executable file → Normal file
View File

0
versionmod/libft/ft_memmove.c Executable file → Normal file
View File

0
versionmod/libft/ft_memset.c Executable file → Normal file
View File

0
versionmod/libft/ft_putchar_fd.c Executable file → Normal file
View File

0
versionmod/libft/ft_putendl_fd.c Executable file → Normal file
View File

0
versionmod/libft/ft_putnbr_fd.c Executable file → Normal file
View File

0
versionmod/libft/ft_putstr_fd.c Executable file → Normal file
View File

0
versionmod/libft/ft_realloc.c Executable file → Normal file
View File

0
versionmod/libft/ft_reallocarray.c Executable file → Normal file
View File

0
versionmod/libft/ft_strcat.c Executable file → Normal file
View File

0
versionmod/libft/ft_strchr.c Executable file → Normal file
View File

0
versionmod/libft/ft_strcmp.c Executable file → Normal file
View File

0
versionmod/libft/ft_strcpy.c Executable file → Normal file
View File

0
versionmod/libft/ft_striteri.c Executable file → Normal file
View File

0
versionmod/libft/ft_strlcat.c Executable file → Normal file
View File

0
versionmod/libft/ft_strlcpy.c Executable file → Normal file
View File

0
versionmod/libft/ft_strmapi.c Executable file → Normal file
View File

0
versionmod/libft/ft_strncmp.c Executable file → Normal file
View File

0
versionmod/libft/ft_strncpy.c Executable file → Normal file
View File

0
versionmod/libft/ft_strnstr.c Executable file → Normal file
View File

0
versionmod/libft/ft_strrchr.c Executable file → Normal file
View File

0
versionmod/libft/ft_strstr.c Executable file → Normal file
View File

0
versionmod/libft/ft_strtok.c Executable file → Normal file
View File

0
versionmod/libft/ft_strtol.c Executable file → Normal file
View File

0
versionmod/libft/ft_strtrim.c Executable file → Normal file
View File

0
versionmod/libft/ft_substr.c Executable file → Normal file
View File

0
versionmod/libft/ft_tolower.c Executable file → Normal file
View File

0
versionmod/libft/ft_toupper.c Executable file → Normal file
View File

0
versionmod/libft/libft.h Executable file → Normal file
View File

View File

@ -6,21 +6,20 @@
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/01/15 18:45:52 by fgras-ca #+# #+# */
/* Updated: 2024/01/16 17:55:57 by fgras-ca ### ########.fr */
/* Updated: 2024/01/17 21:22:18 by fgras-ca ### ########.fr */
/* */
/* ************************************************************************** */
#include "cub3d.h"
int setup_and_load_map(int argc, char **argv, t_structure_main *w)
int setup_and_load_map(int argc, char **argv, t_structure_main *w, t_texture *textures)
{
t_texture textures;
if (argc > 2)
{
fprintf(stderr, "Usage: %s\n", argv[0]);
return (0);
}
if (!load_cub_file("map.cub", &textures, &w->s_map))
if (!load_cub_file("map.cub", textures, &w->s_map))
{
printf("Failed to load the map or map is not closed. Exiting...\n");
return (0);
@ -30,6 +29,10 @@ int setup_and_load_map(int argc, char **argv, t_structure_main *w)
printf("Failed to load the map.\n");
return (0);
}
printf("set_up_andloadmap %s\n", textures->north);
printf("set_up_andloadmap %s\n", textures->south);
printf("set_up_andloadmap %s\n", textures->east);
printf("set_up_andloadmap %s\n", textures->west);
return (1);
}
@ -47,9 +50,12 @@ int main(int argc, char **argv)
global_struct.w = &w;
global_struct.state.jkl = -1;
global_struct.state.yui = 0;
if (!setup_and_load_map(argc, argv, &w))
if (!setup_and_load_map(argc, argv, &w, w.t))
return (1);
load_wall_textures(&w);
printf("main textures %s\n", w.t->north);
printf("main textures %s\n", w.t->south);
printf("main textures %s\n", w.t->east);
printf("main textures %s\n", w.t->west);
init_windows(&w);
mlx_loop_hook(w.s_win.mlx, (void *)sleep_mouse, &global_struct);
mlx_hook(w.s_win.win, 2, 1L << 0, deal_key, &w);

Binary file not shown.

View File

@ -6,7 +6,7 @@
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/01/14 20:09:23 by fgras-ca #+# #+# */
/* Updated: 2024/01/14 20:16:05 by fgras-ca ### ########.fr */
/* Updated: 2024/01/17 21:15:02 by fgras-ca ### ########.fr */
/* */
/* ************************************************************************** */

View File

@ -6,7 +6,7 @@
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/01/14 19:15:53 by fgras-ca #+# #+# */
/* Updated: 2024/01/16 17:55:37 by fgras-ca ### ########.fr */
/* Updated: 2024/01/17 21:26:12 by fgras-ca ### ########.fr */
/* */
/* ************************************************************************** */
@ -92,7 +92,9 @@ void init_windows(t_structure_main *w)
w->s_win.height = HEIGHT;
init_player(w);
init_mlx_and_window(w);
load_textures(w, &temp);
init_buffer(w);
load_wall_textures(w);
printf("Window Dimensions: Width = %d, Height = %d\n",
w->s_win.width, w->s_win.height);
printf("Texture Dimensions: Width = %d, Height = %d\n",

Binary file not shown.