64 lines
No EOL
2.2 KiB
C
64 lines
No EOL
2.2 KiB
C
/* ************************************************************************** */
|
|
/* */
|
|
/* ::: :::::::: */
|
|
/* map.h :+: :+: :+: */
|
|
/* +:+ +:+ +:+ */
|
|
/* By: mcolonna <mcolonna@student.42.fr> +#+ +:+ +#+ */
|
|
/* +#+#+#+#+#+ +#+ */
|
|
/* Created: 2024/10/01 13:59:04 by mcolonna #+# #+# */
|
|
/* Updated: 2024/10/01 14:00:40 by mcolonna ### ########.fr */
|
|
/* */
|
|
/* ************************************************************************** */
|
|
|
|
#ifndef MAP_H
|
|
# define MAP_H
|
|
|
|
/// @brief The type of a case.
|
|
typedef enum e_map_wall
|
|
{
|
|
/// @brief Empty case, for '0' and ' '.
|
|
EMPTY,
|
|
/// @brief A wall, for '1'.
|
|
WALL,
|
|
} t_map_wall;
|
|
|
|
/// @brief An object of the map (player, enemies?)
|
|
typedef struct s_object
|
|
{
|
|
/// @brief Function called when creating the object.
|
|
/// @param data Address of the s_object.data pointer.
|
|
void (*init)(void **data);
|
|
/// @brief Function called when destroying the object (to free everything).
|
|
/// @param data Address of the s_object.data pointer.
|
|
void (*destroy)(void **data);
|
|
/// @brief Function called each tick.
|
|
/// @param data Address of the s_object.data pointer.
|
|
void (*tick)(void **data);
|
|
/// @brief Pointer the object can use to save data.
|
|
void *data;
|
|
} t_object;
|
|
|
|
/// @brief Represents a case of the map.
|
|
typedef struct s_map_case
|
|
{
|
|
/// @brief Is the case empty or a wall?
|
|
t_map_wall wall;
|
|
/// @brief The object that appears on this case. If there is none,
|
|
/// every pointer of the struct will be NULL.
|
|
t_object object;
|
|
} t_map_case;
|
|
|
|
/// @brief Represents a map.
|
|
typedef struct s_map
|
|
{
|
|
/// @brief Width of the map.
|
|
int width;
|
|
/// @brief Height of the map.
|
|
int height;
|
|
/// @brief An 2D array of all the cases.
|
|
/// Syntax to get a case: cases[y][x]
|
|
/// x is left to right, y is top to bottom.
|
|
t_map_case **cases;
|
|
} t_map;
|
|
|
|
#endif |