mirror of
https://github.com/HowestDAE/dae16-VerhulstBram.git
synced 2025-12-16 21:11:47 +01:00
108 lines
2.0 KiB
C++
108 lines
2.0 KiB
C++
#pragma once
|
|
#include "Collision.h"
|
|
#include "TextureManager.h"
|
|
#include "Animations/Animation.h"
|
|
|
|
class WorldLevel;
|
|
|
|
enum class PlayerState
|
|
{
|
|
Idle,
|
|
Walking,
|
|
Digging,
|
|
};
|
|
|
|
enum class PlayerDirection
|
|
{
|
|
Left,
|
|
Right,
|
|
Up,
|
|
Down,
|
|
};
|
|
|
|
enum class DigDirection
|
|
{
|
|
Left,
|
|
Right,
|
|
Down
|
|
};
|
|
|
|
class Player
|
|
{
|
|
public:
|
|
explicit Player(const Vector2f& Position, TextureManager* pTextureManager);
|
|
Player( const Player& other ) = default;
|
|
Player(Player&& other) = default;
|
|
|
|
~Player();
|
|
|
|
Collision::CollisionRect GetCollisionRect() const;
|
|
void Update(float elapsedTime, WorldLevel& level);
|
|
void Draw() const;
|
|
|
|
void SetPosition(Vector2f pos) {
|
|
m_Position = pos;
|
|
}
|
|
Vector2f GetPosition() const {
|
|
return m_Position;
|
|
}
|
|
|
|
void SetVelocity(Vector2f vel) {
|
|
m_Vel = vel;
|
|
}
|
|
Vector2f GetVelocity() const {
|
|
return m_Vel;
|
|
}
|
|
|
|
auto GetContactMap() {
|
|
return m_ContactMap;
|
|
}
|
|
void SetContactMap(Collision::CollisionDirection dir, WorldTile* tile) {
|
|
m_ContactMap[dir] = tile;
|
|
}
|
|
|
|
void ProcessImGui();
|
|
|
|
private:
|
|
void Dig(Collision::CollisionDirection dir, WorldLevel& level);
|
|
bool CanDig(Collision::CollisionDirection dir, WorldLevel& level);
|
|
|
|
Vector2f m_Position;
|
|
Vector2f m_Size;
|
|
|
|
Vector2f m_Vel;
|
|
|
|
std::map<Collision::CollisionDirection, WorldTile *> m_ContactMap;
|
|
|
|
Vector2f m_Acc;
|
|
Vector2f m_Gravity { 0, -9.81f };
|
|
float m_BobTimer{ 0.0f };
|
|
const float m_BobTime{ 0.1f };
|
|
bool m_BobUp{ true };
|
|
|
|
Vector2f m_DigDestination{};
|
|
bool m_Digging{ false };
|
|
Vector2f m_DigStart{};
|
|
float m_DigProgress{};
|
|
bool m_HasDeletedTile{ false };
|
|
WorldTile* m_DigTile{ nullptr };
|
|
|
|
const float m_DigTime{ 0.5f };
|
|
|
|
bool m_Grounded { false };
|
|
|
|
bool m_DidJustDigRight { false };
|
|
bool m_DidJustDigLeft { false };
|
|
Animation* m_currentAnimation{ nullptr };
|
|
Animation* m_walkAnimation;
|
|
Animation* m_turnAnimation;
|
|
Animation* m_digAnimation;
|
|
|
|
PlayerState m_State { PlayerState::Idle };
|
|
PlayerDirection m_Direction { PlayerDirection::Right };
|
|
DigDirection m_DigDirection { DigDirection::Right };
|
|
|
|
//Testing
|
|
bool m_DrawCollisionRect { true };
|
|
};
|