2025-01-19 18:23:50 +01:00
|
|
|
#include "Vector2d.h"
|
2025-01-19 18:20:22 +01:00
|
|
|
#include "GameState.h"
|
2025-01-19 17:59:26 +01:00
|
|
|
|
|
|
|
#ifndef PLAYER_H
|
|
|
|
#define PLAYER_H
|
|
|
|
|
|
|
|
using game::GameState;
|
|
|
|
|
|
|
|
namespace game
|
|
|
|
{
|
|
|
|
class Maze;
|
|
|
|
class Game;
|
|
|
|
|
|
|
|
/// Ein Spieler.
|
|
|
|
/// Besitzt einen veränderbaren Positionsvektor
|
|
|
|
class Player
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
/// Die Position des Spielers
|
|
|
|
Vector2d pos;
|
|
|
|
int keys_in_inventory;
|
|
|
|
|
|
|
|
/// Bewege den Splieler um den Bewegungsvektor, insofern die Zielposition begehbar ist
|
|
|
|
/// @param maze Das Maze
|
|
|
|
/// @param move_vector Die gewollte Bewegung
|
|
|
|
/// @return Die neue Position des Spielers
|
|
|
|
Maze handle_move(Maze& maze, const Vector2d& move_vector);
|
|
|
|
|
|
|
|
/// Gebe oder Nehme dem Spieler Schlüssel
|
|
|
|
/// Updated auch das Maze (Reference!)
|
|
|
|
/// @param maze Das Maze
|
|
|
|
void handle_keys(Maze& maze);
|
|
|
|
|
|
|
|
/// Kontrolliere, ob der Spieler gerade in einem Geist steht
|
|
|
|
/// @param maze Das Maze
|
|
|
|
GameState handle_collisions(const Game& game, const Maze& maze) const;
|
|
|
|
|
|
|
|
public:
|
|
|
|
/// Ein Spieler.
|
|
|
|
/// Besitzt einen veränderbaren Positionsvektor
|
|
|
|
/// @param target_x Die Startposition des Spielers (X-Koordinate)
|
|
|
|
/// @param target_y Die Startposition des Spielers (Y-Koordinate)
|
|
|
|
Player(int target_x, int target_y);
|
|
|
|
|
|
|
|
/// Ein Spieler
|
|
|
|
/// @param pos Die Startposition des Spielers
|
|
|
|
explicit Player(Vector2d pos);
|
|
|
|
|
|
|
|
/// Kriege die Position des Spielers
|
|
|
|
/// @return Die Position des Spielers
|
|
|
|
Vector2d get_pos() const;
|
|
|
|
|
|
|
|
/// Aktuallisiere die Position des Spielers ohne weitere Checks
|
|
|
|
/// @param target Das ziel
|
|
|
|
void update_position(const Vector2d& target);
|
|
|
|
|
|
|
|
/// Behandle die eingabe des Nutzers für den Spieler
|
|
|
|
/// @param maze Das Labyrinth
|
|
|
|
/// @param input Die Eingabe des Nutzers
|
|
|
|
Maze handle_user_input(Maze& maze, const char& input);
|
|
|
|
|
|
|
|
/// Halte den Spieler aktuell
|
|
|
|
/// @param game Das Spiel
|
|
|
|
/// @param maze Das Labyrinth
|
|
|
|
/// @returns Der Status des Spiels
|
|
|
|
GameState tick(const Game& game, Maze& maze);
|
|
|
|
|
|
|
|
/// Check, if a player has at least one key
|
|
|
|
/// @return If the player as an available key
|
|
|
|
bool has_key_available() const;
|
|
|
|
};
|
|
|
|
} // maze
|
|
|
|
|
|
|
|
#endif //PLAYER_H
|