Changes to player, and mesh renderer INCOMPLETE
This commit is contained in:
68
Player.h
68
Player.h
@@ -3,41 +3,59 @@
|
||||
#include <glad/glad.h>
|
||||
#include <glm/glm.hpp>
|
||||
#include <glm/gtc/matrix_transform.hpp>
|
||||
#include <glm/geometric.hpp>
|
||||
#include <GameObject.h>
|
||||
#include <Camera.h>
|
||||
#include <LevelMap.h>
|
||||
#include <InputEnums.h>
|
||||
#include <memory>
|
||||
|
||||
|
||||
enum EInputDirection
|
||||
{
|
||||
FORWARD,
|
||||
BACKWARD,
|
||||
LEFT,
|
||||
RIGHT
|
||||
};
|
||||
class PlayerInputComponent;
|
||||
|
||||
class Player : public GameObject
|
||||
{
|
||||
public:
|
||||
Player(glm::vec3 Position, glm::vec3 Rotation);
|
||||
~Player() = default;
|
||||
|
||||
void Update();
|
||||
|
||||
void ProcessKeyboard(EInputDirection Direction, float Delta);
|
||||
void ProcessMouseMovement(float XOffset, float YOffset, GLboolean ConstrainPitch = true);
|
||||
glm::mat4 GetViewMatrix() const;
|
||||
|
||||
private:
|
||||
Camera* PlayerCamera;
|
||||
float Yaw;
|
||||
float MouseSensitivity;
|
||||
|
||||
std::vector<Sector>& LevelSectors;
|
||||
Sector* CurrentSector;
|
||||
float Yaw = -90.0f;
|
||||
float MouseSensitivity = 0.1f;
|
||||
|
||||
// movement variables
|
||||
float WalkSpeed = 5.0f;
|
||||
float RunSpeed = 15.0f;
|
||||
|
||||
bool bIsRunning = false;
|
||||
|
||||
void UpdatePlayerVectors();
|
||||
float JumpForce = 5.0f;
|
||||
float JumpVelocity = 0.0f;
|
||||
bool bJumping = false;
|
||||
const float GRAVITY = 9.8f;
|
||||
|
||||
// collision constants
|
||||
const float STEP_HEIGHT = 0.25f;
|
||||
const float PLAYER_HEIGHT = 2.0f;
|
||||
const float PLAYER_RADIUS = 1.0f;
|
||||
|
||||
bool CrossingWall(glm::vec3 NewPosition);
|
||||
bool LineSegmentsIntersect(const glm::vec2& p1, const glm::vec2& p2, const glm::vec2& q1, const glm::vec2& q2);
|
||||
float PointToLineSegmentDistance(const glm::vec2& point, const glm::vec2& segA, const glm::vec2& segB);
|
||||
bool PointInPolygon(glm::vec2 point, std::vector<Wall> polygon);
|
||||
bool CanFitInNextSector(Sector Sector);
|
||||
|
||||
std::unique_ptr<PlayerInputComponent> cPlayerInput;
|
||||
|
||||
public:
|
||||
std::unique_ptr<Camera> PlayerCamera;
|
||||
|
||||
Player(glm::vec3 Position, glm::vec3 Rotation, std::vector<Sector>& LevelSectors, GLFWwindow* Window);
|
||||
~Player() = default;
|
||||
|
||||
void Update(float DeltaTime);
|
||||
void Move(EInputDirection Direction, float Delta);
|
||||
void Jump();
|
||||
void Sprint();
|
||||
void StopSprint();
|
||||
void Look(float XOffset, float YOffset, GLboolean bConstrainPitch = true);
|
||||
|
||||
glm::mat4 GetViewMatrix() const;
|
||||
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user