v1.0 - normed texture system, multiple keypress, fixes on parsing, removed trailing maps

This commit is contained in:
B.Goulard 2024-12-16 14:56:22 +01:00
parent e581c72b02
commit 3f43074d05
35 changed files with 474 additions and 438 deletions

View file

@ -6,7 +6,7 @@
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/10/31 11:09:00 by rparodi #+# #+# */
/* Updated: 2024/11/27 12:00:34 by bgoulard ### ########.fr */
/* Updated: 2024/12/16 14:37:11 by bgoulard ### ########.fr */
/* */
/* ************************************************************************** */
@ -17,7 +17,7 @@
#include <unistd.h>
const char *const g_error_message[] = {
static const char *g_error_message[] = {
"no error",
"unknown error",
"could not open file",
@ -27,6 +27,9 @@ const char *const g_error_message[] = {
"missing file",
"malloc error",
"parse error",
"map open error",
"bad format for background color",
"variable was set multiple times",
"cli error",
"mlx error",
"texture format error",

View file

@ -6,7 +6,7 @@
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/10/30 16:30:03 by rparodi #+# #+# */
/* Updated: 2024/12/01 18:53:12 by rparodi ### ########.fr */
/* Updated: 2024/12/16 09:38:44 by bgoulard ### ########.fr */
/* */
/* ************************************************************************** */
@ -19,69 +19,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
void dump_map(t_tile *map, t_ipoint size)
{
int i;
int j;
i = 0;
while (i < size.y)
{
j = 0;
printf("\t\t\t");
while (j < size.x)
{
printf("%d", map[i * size.x + j].tile_type);
j++;
}
printf("\n");
i++;
}
}
// not normed but we'll take care of this as a niceties at the last
// possible moment :)
void dump_info(t_info *info)
{
const char *bool_str[2] = {"False", "True"};
size_t i;
i = 0;
printf("t_info:\n");
printf("\tplayer:\n");
printf("\t\tpos_i:\t(x: %d, y:%d)\n", \
info->player.pos_i.x, info->player.pos_i.y);
printf("\t\tpos:\t(x:%lf, y:%lf)\n", \
info->player.pos.x, info->player.pos.y);
printf("\t\tdir:\t(x:%lf, y:%lf)\n", \
info->player.dir.x, info->player.dir.y);
printf("\t\tplane:\t(x:%lf, y:%lf)\n", \
info->player.plane.x, info->player.plane.y);
printf("\tcli_ctx:\n");
printf("\t\tfile:\t%s\n", info->cli_ctx.file);
printf("\t\tdebug:\t%s\n", bool_str[info->cli_ctx.debug]);
printf("\t\tsave:\t%s\n", bool_str[info->cli_ctx.save]);
printf("\t\thelp:\t%s\n", bool_str[info->cli_ctx.help]);
printf("\tmap:\n");
printf("\t\tpath:%s\n", info->map.path);
printf("\t\tfd:\t%d\n", info->map.fd);
printf("\t\tsize:\t(x:%d, y:%d)\n", info->map.size.x, info->map.size.y);
while (info->map.fraw[i])
{
printf("\t\tmap.fraw[%*zu]: %s\n", 3, i, info->map.fraw[i]);
i++;
}
printf("\t\ttexture[0]: %p\n", info->map.texture[0]);
printf("\t\ttexture[1]: %p\n", info->map.texture[1]);
printf("\t\ttexture[2]: %p\n", info->map.texture[2]);
printf("\t\ttexture[3]: %p\n", info->map.texture[3]);
printf("\t\tmap: %p\n", info->map.map);
dump_map(info->map.map, info->map.size);
printf("\tlast_error: %d\n", info->last_error);
printf("\terno_state: %d\n", info->errno_state);
printf("\n");
}
#include <unistd.h>
void check_err(t_info *info)
{
@ -103,13 +41,16 @@ void run_cub3d(t_info *info)
return ;
parse_map(info);
if (info->cli_ctx.debug)
dump_info(info);
ft_putstr_fd("no debug mod on production run", STDERR_FILENO);
if (info->last_error != NO_ERROR)
return ;
if (info->cli_ctx.no_graphics == true)
return ;
info->camera.screen_buff = mlx_new_image(info->mlx_ptr, info->screen_size.x,
info->screen_size.y);
info->camera.img_addr = mlx_get_data_addr(info->camera.screen_buff,
&info->camera.bpp, &info->camera.line_len, &info->camera.endian);
info->redraw = true;
mlx_loop(info->mlx_ptr);
}