mirror of
https://github.com/HowestDAE/dae16-VerhulstBram.git
synced 2026-02-04 12:19:21 +01:00
84 lines
1.3 KiB
C++
84 lines
1.3 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:
|
|
Player(const Point2f& Position, TextureManager* pTextureManager);
|
|
Collision::CollisionRect GetCollisionRect() const;
|
|
void Update(float elapsedTime, WorldLevel& level);
|
|
void Draw() const;
|
|
|
|
void SetPosition(Point2f pos) {
|
|
m_Position = pos;
|
|
}
|
|
Point2f GetPosition() const {
|
|
return m_Position;
|
|
}
|
|
|
|
void SetVelocity(Point2f vel) {
|
|
m_Vel = vel;
|
|
}
|
|
Point2f GetVelocity() const {
|
|
return m_Vel;
|
|
}
|
|
|
|
auto GetContactMap() {
|
|
return m_ContactMap;
|
|
}
|
|
void SetContactMap(Collision::CollisionDirection dir, WorldTile* tile) {
|
|
m_ContactMap[dir] = tile;
|
|
}
|
|
|
|
void ProcessImGui();
|
|
|
|
private:
|
|
Point2f m_Position;
|
|
Point2f m_Size;
|
|
|
|
Point2f m_Vel;
|
|
|
|
std::map<Collision::CollisionDirection, WorldTile *> m_ContactMap;
|
|
|
|
Point2f m_Acc;
|
|
Point2f m_Gravity { 0, -9.81f };
|
|
|
|
bool m_Grounded { false };
|
|
|
|
bool m_DidJustDigRight { false };
|
|
Animation* m_walkAnimation;
|
|
|
|
PlayerState m_State { PlayerState::Idle };
|
|
PlayerDirection m_Direction { PlayerDirection::Right };
|
|
DigDirection m_DigDirection { DigDirection::Right };
|
|
|
|
//Testing
|
|
bool m_DrawCollisionRect { true };
|
|
};
|