clean code *

- add constants for each minimap color
- rename, reorganize and make static minimap functions
- main.c:draw_screen() calls draw_minimap() instead of render().
- clean code and norm
This commit is contained in:
mcolonna 2024-11-18 14:13:08 +01:00
parent 57b099d013
commit e7d5a5ce69
6 changed files with 88 additions and 72 deletions

View file

@ -3,10 +3,10 @@
/* ::: :::::::: */
/* const.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: grobledo <grobledo@student.42.fr> +#+ +:+ +#+ */
/* By: mcolonna <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/10/31 17:00:59 by mcolonna #+# #+# */
/* Updated: 2024/11/15 14:58:24 by grobledo ### ########.fr */
/* Updated: 2024/11/18 13:40:04 by mcolonna ### ########.fr */
/* */
/* ************************************************************************** */
@ -27,5 +27,9 @@
# define FOV 0.66 // Width of the view plane (unit: cases)
# define MINIMAP_SCALE 8
# define MINIMAP_SCALE 8 // Size of a case on the minimap.
# define MINIMAP_COLOR_WALL 0xFFAF33 // Color of the walls on the minimap
# define MINIMAP_COLOR_EMPTY 0xFFFC33 // Color of the empty cases on the minimap
# define MINIMAP_COLOR_PLAYER 0xFF0000 // Color of the player on the minimap
#endif

View file

@ -3,10 +3,10 @@
/* ::: :::::::: */
/* map.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: grobledo <grobledo@student.42.fr> +#+ +:+ +#+ */
/* By: mcolonna <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/10/01 13:59:04 by mcolonna #+# #+# */
/* Updated: 2024/11/15 14:56:55 by grobledo ### ########.fr */
/* Updated: 2024/11/12 15:10:07 by mcolonna ### ########.fr */
/* */
/* ************************************************************************** */
@ -157,8 +157,4 @@ bool check_map(const t_map *map);
/// @return Wanted case.
const t_map_case *map_get_case(const t_map *map, int x, int y);
void create_minimap(u_int32_t *img_data);
void draw_minimap(uint32_t *img_data, int map_x, int map_y);
void minimap_player(u_int32_t *img_data);
#endif

22
include/minimap.h Normal file
View file

@ -0,0 +1,22 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* minimap.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mcolonna <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/11/18 13:09:05 by mcolonna #+# #+# */
/* Updated: 2024/11/18 13:14:12 by mcolonna ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef MINIMAP_H
# define MINIMAP_H
# include "utils.h"
/// @brief Draw the minimap on the image.
/// @param img_data Data of the image to draw the minimap on.
void draw_minimap(u_int32_t *img_data);
#endif