Collab_RPG/src/player.h

52 lines
1.4 KiB
C
Raw Normal View History

#ifndef PLAYER_H
#define PLAYER_H
#include <stdbool.h>
#include "mapstruct.h"
#include "memory.h"
/* The direction where the player is going to. */
typedef enum {
D_UP,
D_DOWN,
D_LEFT,
D_RIGHT
} Direction;
typedef enum {
P_LEFTUP = -1,
P_CENTER = 0,
P_RIGHTDOWN = 1
} Checkpos;
/* Struct that define player parameters */
typedef struct {
int x, y; /* The position of the player */
2023-07-07 14:50:30 +02:00
unsigned char px, py; /* The position of the player on screen */
unsigned short int life; /* How many lives the player still has between 0
* and 100. */
} Player;
/* Draws the player player. This function should be called after drawing the
* map! */
void player_draw(Player *player);
/* Move the player player in the direction direction. */
void player_move(Map *map_level, Player *player, Direction direction);
/* (Mibi88) TODO: Describe this function please, I've no idea what she's for! */
void player_action(Player *player);
/* Check if the player is in collision with the map or a NPC. Checkpos is used
* to check the axis where the player is not moving. */
bool player_collision(Map *map_level, Player *player, Direction direction,
Checkpos nomov_axis_check);
/* Fix the position of the player so that he's not a bit inside of a hard block
* after a collision. */
void player_fix_position(Player *player, bool fix_x, bool fix_y);
#endif