38 lines
893 B
C++
38 lines
893 B
C++
#pragma once
|
|
|
|
#include <raylib.h>
|
|
#include <raymath.h>
|
|
|
|
class PlayerController {
|
|
private:
|
|
Camera3D camera{};
|
|
Vector3 playerPosition{0, 0, 0};
|
|
float cameraDistance;
|
|
float cameraHeight;
|
|
float moveSpeed;
|
|
|
|
float cameraYaw{0.0f};
|
|
float cameraPitch{0.3f};
|
|
|
|
bool isRightMouseDown{false};
|
|
Vector2 lastMousePos{0, 0};
|
|
|
|
public:
|
|
PlayerController(float distance = 10.0f, float height = 5.0f, float speed = 5.0f);
|
|
|
|
void update(float deltaTime);
|
|
void setPlayerPosition(const Vector3& position);
|
|
Vector3 getPlayerPosition() const { return playerPosition; }
|
|
|
|
Vector3 getMoveInput() const;
|
|
Camera3D& getCamera() { return camera; }
|
|
|
|
float getCameraYaw() const { return cameraYaw; }
|
|
float getCameraPitch() const { return cameraPitch; }
|
|
|
|
private:
|
|
void updateCameraPosition();
|
|
void handleCameraRotation();
|
|
void handleCameraZoom();
|
|
};
|