This commit is contained in:
Ladebeze66
2024-01-22 16:33:54 +01:00
parent 6d8196504c
commit 84c17810af
13 changed files with 49 additions and 63 deletions

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/21 14:33:45 by fgras-ca ### ########.fr */
/* Updated: 2024/01/22 14:16:09 by fgras-ca ### ########.fr */
/* */
/* ************************************************************************** */
@@ -14,48 +14,35 @@
void init_player(t_structure_main *w)
{
// Ajouter des logs pour vérifier les valeurs
printf("Initialisation du joueur:\n");
printf("Position X: %f\n", w->s_map.player_x);
printf("Position Y: %f\n", w->s_map.player_y);
//printf("Initialisation du joueur:\n");
w->s_player.px = w->s_map.player_x;
w->s_player.py = w->s_map.player_y;
if (w->s_map.player_direction == 'N')
{
w->s_player.pa = M_PI;
w->s_player.pdx = 0;
w->s_player.pdy = -5;
}
else if (w->s_map.player_direction == 'S')
{
w->s_player.pa = 0;
w->s_player.pdx = 0;
w->s_player.pdy = 5;
}
else if (w->s_map.player_direction == 'E')
{
w->s_player.pa = M_PI / 2;
w->s_player.pdx = 5;
w->s_player.pdy = 0;
}
else if (w->s_map.player_direction == 'W')
{
w->s_player.pa = 3 * M_PI / 2;
w->s_player.pdx = -5;
w->s_player.pdy = 0;
}
// Ajouter des logs pour vérifier les valeurs après l'initialisation
w->s_player.pdx = cos(w->s_player.pa) * 5;
w->s_player.pdy = sin(w->s_player.pa) * 5;
printf("Angle de direction: %f radians\n", w->s_player.pa);
printf("Vecteur de déplacement X: %f\n", w->s_player.pdx);
printf("Vecteur de déplacement Y: %f\n", w->s_player.pdy);
//printf("Vecteur de déplacement X: %f\n", w->s_player.pdx);
//printf("Vecteur de déplacement Y: %f\n", w->s_player.pdy);
}
void init_mlx_and_window(t_structure_main *w)
{
w->s_win.mlx = mlx_init();

Binary file not shown.

View File

@@ -6,7 +6,7 @@
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/01/15 19:50:24 by fgras-ca #+# #+# */
/* Updated: 2024/01/21 21:10:56 by fgras-ca ### ########.fr */
/* Updated: 2024/01/22 15:41:55 by fgras-ca ### ########.fr */
/* */
/* ************************************************************************** */
@@ -29,23 +29,23 @@ void rescale_sprite(t_structure_main *w, t_state *state) {
void refresh_window(t_structure_main *w, t_state *state)
{
printf("refresh_window: Destroying old image\n");
//printf("refresh_window: Destroying old image\n");
mlx_destroy_image(w->s_win.mlx, w->s_img.buffer);
//printf("refresh_window: Creating new image\n");
w->s_img.buffer = mlx_new_image(w->s_win.mlx, w->s_win.width,
w->s_win.height);
//printf("refresh_window: Getting data address\n");
printf("refresh_window: Getting data address\n");
w->s_img.addr = mlx_get_data_addr(w->s_img.buffer,
&(w->s_img.bpp), &(w->s_img.line_len), &(w->s_img.endian));
//printf("refresh_window: Drawing map\n");
printf("refresh_window: Drawing map\n");
draw_map(w);
//printf("refresh_window: Drawing rays 2D\n");
printf("refresh_window: Drawing rays 2D\n");
drawrays2d(w);
//printf("refresh_window: Putting image to window\n");
mlx_put_image_to_window(w->s_win.mlx, w->s_win.win, w->s_img.buffer, 0, 0);
//printf("refresh_window: Rescaling sprite\n");
rescale_sprite(w, state);
printf("refresh_window: Window refreshed\n");
//printf("refresh_window: Window refreshed\n");
}
void handle_mouse_movement(t_structure_main *w)