「✏️」 norm: Cleand and normed player on minimap
This commit is contained in:
@ -6,14 +6,14 @@
|
||||
/* By: madumerg <madumerg@42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/09/04 17:01:05 by madumerg #+# #+# */
|
||||
/* Updated: 2024/09/12 12:54:48 by madumerg ### ########.fr */
|
||||
/* Updated: 2024/09/17 10:40:27 by adjoly ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef CUB3D_H
|
||||
# define CUB3D_H
|
||||
|
||||
# include "../libft/includes/libft.h"
|
||||
# include "libft.h"
|
||||
# include "mess_err.h"
|
||||
# include <stdlib.h>
|
||||
# include <math.h>
|
||||
@ -22,5 +22,4 @@
|
||||
# include <stdio.h>
|
||||
# include "parsing.h"
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/09/11 16:38:40 by adjoly #+# #+# */
|
||||
/* Updated: 2024/09/16 13:36:04 by adjoly ### ########.fr */
|
||||
/* Updated: 2024/09/17 10:47:26 by adjoly ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -16,11 +16,12 @@
|
||||
# include "parsing.h"
|
||||
# include <stdint.h>
|
||||
|
||||
typedef struct s_cub
|
||||
typedef struct s_cub
|
||||
{
|
||||
void *mlx;
|
||||
void *win;
|
||||
void *images;
|
||||
void *sprites;
|
||||
void *img;
|
||||
char **map;
|
||||
t_coord p_coord;
|
||||
} t_cub;
|
||||
@ -42,12 +43,13 @@ typedef struct s_cub
|
||||
*
|
||||
* @return Minilibx go brrrr(useless always 0)
|
||||
*/
|
||||
int key_hook(int key, void *param);
|
||||
int key_hook(int key, void *param);
|
||||
|
||||
/**
|
||||
* @brief This function is used to create an image with the player position
|
||||
*
|
||||
* @param cub The address of a t_cub struct filled with mlx data and other thing
|
||||
* @param cub The address of a t_cub struct filled with mlx data and other
|
||||
* thing
|
||||
*
|
||||
*/
|
||||
void *get_player_image(t_cub *cub, uint8_t key_pressed);
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: madumerg <madumerg@42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/09/04 16:58:27 by madumerg #+# #+# */
|
||||
/* Updated: 2024/09/16 18:39:38 by adjoly ### ########.fr */
|
||||
/* Updated: 2024/09/17 10:36:01 by adjoly ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -24,13 +24,10 @@ int main(int ac, char **av)
|
||||
cub.win = mlx_new_window(cub.mlx, 400, 400, "WTF");
|
||||
cub.p_coord.x = 100;
|
||||
cub.p_coord.y = 100;
|
||||
|
||||
mlx_put_image_to_window(cub.mlx, cub.win, get_player_image(&cub, 0), 0, 0);
|
||||
|
||||
cub.img = get_player_image(&cub, 0);
|
||||
mlx_put_image_to_window(cub.mlx, cub.win, cub.img, 0, 0);
|
||||
mlx_on_event(cub.mlx, cub.win, MLX_KEYDOWN, key_hook, &cub);
|
||||
|
||||
mlx_loop(cub.mlx);
|
||||
|
||||
mlx_destroy_window(cub.mlx, cub.win);
|
||||
mlx_destroy_display(cub.mlx);
|
||||
return (0);
|
||||
|
@ -1,12 +1,12 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* event_handler.c :+: :+: :+: */
|
||||
/* key_hook.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/09/11 16:37:56 by adjoly #+# #+# */
|
||||
/* Updated: 2024/09/16 18:47:09 by adjoly ### ########.fr */
|
||||
/* Updated: 2024/09/17 10:33:35 by adjoly ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -21,30 +21,16 @@ int key_hook(int key, void *param)
|
||||
cub = (t_cub *)param;
|
||||
(void)cub;
|
||||
if (key == ESCAPE_KEY)
|
||||
{
|
||||
mlx_loop_end(cub->mlx);
|
||||
if (key == W_KEY)
|
||||
{
|
||||
printf("UP\n");
|
||||
mlx_clear_window(cub->mlx, cub->win);
|
||||
mlx_put_image_to_window(cub->mlx, cub->win, get_player_image(cub, key), 0, 0);
|
||||
mlx_destroy_image(cub->mlx, cub->img);
|
||||
}
|
||||
if (key == S_KEY)
|
||||
if (key == W_KEY || key == S_KEY || key == D_KEY || key == A_KEY)
|
||||
{
|
||||
printf("DOWN\n");
|
||||
mlx_clear_window(cub->mlx, cub->win);
|
||||
mlx_put_image_to_window(cub->mlx, cub->win, get_player_image(cub, key), 0, 0);
|
||||
}
|
||||
if (key == D_KEY)
|
||||
{
|
||||
printf("RIGHT\n");
|
||||
mlx_clear_window(cub->mlx, cub->win);
|
||||
mlx_put_image_to_window(cub->mlx, cub->win, get_player_image(cub, key), 0, 0);
|
||||
}
|
||||
if (key == A_KEY)
|
||||
{
|
||||
printf("LEFT\n");
|
||||
mlx_clear_window(cub->mlx, cub->win);
|
||||
mlx_put_image_to_window(cub->mlx, cub->win, get_player_image(cub, key), 0, 0);
|
||||
mlx_destroy_image(cub->mlx, cub->img);
|
||||
cub->img = get_player_image(cub, key);
|
||||
mlx_put_image_to_window(cub->mlx, cub->win, cub->img, 0, 0);
|
||||
}
|
||||
return (0);
|
||||
}
|
@ -6,7 +6,7 @@
|
||||
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/09/13 11:05:02 by adjoly #+# #+# */
|
||||
/* Updated: 2024/09/16 18:49:37 by adjoly ### ########.fr */
|
||||
/* Updated: 2024/09/17 10:30:44 by adjoly ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -19,7 +19,6 @@ void *get_player_image(t_cub *cub, uint8_t key_pressed)
|
||||
void *img;
|
||||
|
||||
img = mlx_new_image(cub->mlx, WINDOW_X, WINDOW_Y);
|
||||
|
||||
if (key_pressed == W_KEY)
|
||||
cub->p_coord.y--;
|
||||
else if (key_pressed == S_KEY)
|
||||
|
Reference in New Issue
Block a user