mirror of
https://github.com/zhenyan121/Cubed.git
synced 2026-04-10 06:14:07 +08:00
fix: movement speed tied to frame rate
This commit is contained in:
3
include/Cubed/config.hpp
Normal file
3
include/Cubed/config.hpp
Normal file
@@ -0,0 +1,3 @@
|
||||
#pragma once
|
||||
constexpr int WORLD_SIZE_X = 32;
|
||||
constexpr int WORLD_SIZE_Z = 32;
|
||||
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
#include <glm/glm.hpp>
|
||||
|
||||
#include <Cubed/config.hpp>
|
||||
struct MoveState {
|
||||
bool forward = false;
|
||||
bool back = false;
|
||||
@@ -14,6 +15,8 @@ struct MoveState {
|
||||
class Player {
|
||||
private:
|
||||
|
||||
bool** m_blockPresent;
|
||||
|
||||
float m_yaw;
|
||||
float m_pitch;
|
||||
|
||||
@@ -21,7 +24,7 @@ private:
|
||||
|
||||
float m_speed = 0.1f;
|
||||
// player is tow block tall, the pos is the lower pos
|
||||
glm::vec3 m_playerPos;
|
||||
glm::vec3 m_playerPos = glm::vec3(0.0f, 5.0f, 0.0f);
|
||||
glm::vec3 m_front = glm::vec3(0, 0, -1);
|
||||
glm::vec3 m_right;
|
||||
MoveState m_moveState;
|
||||
@@ -32,6 +35,8 @@ public:
|
||||
const glm::vec3& getFront() const;
|
||||
const glm::vec3& getPlayerPos() const;
|
||||
const MoveState& getMoveState() const;
|
||||
|
||||
void init(bool** blockPresent);
|
||||
void setPlayerPos(const glm::vec3& pos);
|
||||
void update(float deltaTime);
|
||||
void updateFrontVec(float offsetX, float offsetY);
|
||||
|
||||
Reference in New Issue
Block a user