2023-07-06 22:02:37 +02:00
|
|
|
#ifndef PLAYER_H
|
|
|
|
#define PLAYER_H
|
|
|
|
|
2023-07-08 15:55:06 +02:00
|
|
|
#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;
|
|
|
|
|
2023-07-06 22:49:29 +02:00
|
|
|
/* Struct that define player parameters */
|
2023-07-07 14:20:13 +02:00
|
|
|
typedef struct {
|
|
|
|
unsigned short 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 */
|
2023-07-07 14:20:13 +02:00
|
|
|
unsigned short int life; /* How many lives the player still has between 0
|
|
|
|
* and 100. */
|
|
|
|
} Player;
|
2023-07-06 22:02:37 +02:00
|
|
|
|
2023-07-08 15:55:06 +02:00
|
|
|
/* Draws the player player. This function should be called after drawing the
|
|
|
|
* map! */
|
|
|
|
void player_draw(Player *player);
|
2023-07-06 22:02:37 +02:00
|
|
|
|
2023-07-08 15:55:06 +02:00
|
|
|
/* Move the player player in the direction direction. */
|
|
|
|
void player_move(Map *map_level, Player *player, Direction direction);
|
2023-07-06 22:02:37 +02:00
|
|
|
|
2023-07-08 15:55:06 +02:00
|
|
|
/* (Mibi88) TODO: Describe this function please, I've no idea what she's for! */
|
|
|
|
void player_action(Player *player);
|
2023-07-06 22:02:37 +02:00
|
|
|
|
2023-07-08 15:55:06 +02:00
|
|
|
/* Check if the player is in collision with the map or a NPC. */
|
|
|
|
bool player_collision(Map *map_level, Player *player, Direction direction);
|
2023-07-06 22:02:37 +02:00
|
|
|
|
2023-07-08 15:55:06 +02:00
|
|
|
/* 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);
|
2023-07-06 22:02:37 +02:00
|
|
|
|
2023-07-07 14:20:13 +02:00
|
|
|
#endif
|
2023-07-08 15:55:06 +02:00
|
|
|
|