Collab_RPG/src/player.h

71 lines
1.8 KiB
C
Raw Normal View History

#ifndef PLAYER_H
#define PLAYER_H
#include "config.h"
#include "game.h"
#include "memory.h"
2024-07-29 11:36:11 +02:00
#include <stdbool.h>
2024-07-27 17:20:06 +02:00
typedef struct {
const char *name;
bopti_image_t *face;
} Face;
#define FACES 4
/* Structure 'Player' has been moved to game.h */
/* to avoid circular references between map.h, game.h and player.h */
/* only methods propotypes are now in dedicated header files */
2024-07-25 13:07:19 +02:00
/* player_draw()
2024-07-29 11:36:11 +02:00
*
2024-07-25 13:07:19 +02:00
* Draws the player. This function should be called after drawing the
* map!
* game: The game struct which contains the player struct used.
*/
void player_draw(Game *game);
2024-07-25 13:07:19 +02:00
/* player_move()
2024-07-29 11:36:11 +02:00
*
2024-07-25 13:07:19 +02:00
* Move the player in a direction.
* game: The game struct.
* direction: The direction to move the player in.
*/
void player_move(Game *game, Direction direction);
2024-07-31 20:10:45 +02:00
/*Tries to do an action based on previously set flags (called if the shift key
* is pressed)*/
void player_action(Game *game);
2024-07-25 13:07:19 +02:00
/* player_collision()
2024-07-29 11:36:11 +02:00
*
2024-07-25 13:07:19 +02:00
* 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.
* game: The game struct.
* direction: The direction the player is moving in.
* nomov_axis_check: The axis that isn't changed by this movement.
*/
bool player_collision(Game *game, Direction direction,
Checkpos nomov_axis_check);
2024-07-25 13:07:19 +02:00
/* player_fix_position()
2024-07-29 11:36:11 +02:00
*
2024-07-25 13:07:19 +02:00
* Fix the position of the player so that he's not a bit inside of a hard block
* after a collision.
* game: The game struct.
* fix_x: If we should fix the position on the X axis.
* fix_y: If we should fix the position on the Y axis.
*/
void player_fix_position(Game *game, bool fix_x, bool fix_y);
2024-07-25 13:07:19 +02:00
/* player_damage()
2024-07-29 11:36:11 +02:00
*
2024-07-25 13:07:19 +02:00
* Apply damage to player
* game: The game struct.
* amount: The amount of damage to apply.
*/
void player_damage(Game *game, int amount);
#endif