fix: add check for 0 or 2+ players on a map
This commit is contained in:
commit
51d20f95d9
10 changed files with 115 additions and 81 deletions
|
|
@ -6,7 +6,7 @@
|
|||
/* By: mcolonna <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/10/01 13:59:04 by mcolonna #+# #+# */
|
||||
/* Updated: 2024/11/12 15:10:07 by mcolonna ### ########.fr */
|
||||
/* Updated: 2024/11/18 14:26:30 by mcolonna ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -26,30 +26,7 @@ typedef enum e_map_wall
|
|||
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.
|
||||
/// @param pos Start position of the object.
|
||||
void (*init)(void **data, t_point_int pos);
|
||||
|
||||
/// @brief Function called when destroying the object (to avoid leaks).
|
||||
///
|
||||
/// @param data Address of the s_object.data pointer.
|
||||
/// @param pos Start position of the object.
|
||||
void (*destroy)(void **data, t_point_int pos);
|
||||
|
||||
/// @brief Function called each tick.
|
||||
///
|
||||
/// @param data Address of the s_object.data pointer.
|
||||
/// @param pos Start position of the object.
|
||||
void (*tick)(void **data, t_point_int pos);
|
||||
|
||||
/// @brief Pointer the object can use to save data.
|
||||
void *data;
|
||||
} t_object;
|
||||
typedef struct s_player t_player;
|
||||
|
||||
/// @brief Represents a case of the map.
|
||||
typedef struct s_map_case
|
||||
|
|
@ -60,9 +37,10 @@ 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;
|
||||
/// @brief Initialize the player. NULL if there is no player on this case.
|
||||
/// @param dest Will be set to the player.
|
||||
/// @param pos Position of the case the player is on.
|
||||
void (*init_player)(t_player *dest, t_point_int pos);
|
||||
} t_map_case;
|
||||
|
||||
/// @brief Each element of g_map_mapping. A case and its associated char.
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: mcolonna <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/10/15 17:31:35 by mcolonna #+# #+# */
|
||||
/* Updated: 2024/11/01 20:41:30 by mcolonna ### ########.fr */
|
||||
/* Updated: 2024/11/15 15:54:36 by mcolonna ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -16,17 +16,18 @@
|
|||
# include "include.h"
|
||||
|
||||
# include "utils.h"
|
||||
# include "map.h"
|
||||
|
||||
/// @brief Create a player facing north (to use with t_object.init).
|
||||
void init_player_n(void **data, t_point_int pos);
|
||||
/// @brief Create a player facing north (to use with t_map_case.init_player).
|
||||
void init_player_n(t_player *dest, t_point_int pos);
|
||||
|
||||
/// @brief Create a player facing south (to use with t_object.init).
|
||||
void init_player_s(void **data, t_point_int pos);
|
||||
/// @brief Create a player facing south (to use with t_map_case.init_player).
|
||||
void init_player_s(t_player *dest, t_point_int pos);
|
||||
|
||||
/// @brief Create a player facing west (to use with t_object.init).
|
||||
void init_player_w(void **data, t_point_int pos);
|
||||
/// @brief Create a player facing west (to use with t_map_case.init_player).
|
||||
void init_player_w(t_player *dest, t_point_int pos);
|
||||
|
||||
/// @brief Create a player facing east (to use with t_object.init).
|
||||
void init_player_e(void **data, t_point_int pos);
|
||||
/// @brief Create a player facing east (to use with t_map_case.init_player).
|
||||
void init_player_e(t_player *dest, t_point_int pos);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue