-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathPlayer.h
112 lines (103 loc) · 3.46 KB
/
Player.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
//
// Created by josep on 2/8/2024.
//
#ifndef GAME1_PLAYER_H
#define GAME1_PLAYER_H
#include <raylib.h>
#include <raymath.h>
#include "PacketBuffer.h"
#include <iostream>
#include "Bullet.h"
#include "vector"
#endif
//GAME1_PLAYER_H
//TODO implement player collision and hitbox, potentially uI too or atleast hands and a gun
//TODO test implementation of maps and collisions with those
using namespace std;
struct FPSClientState {
float dt{};
Vector3 separationVector{};
bool topCollision = false;
float Gravity = -0.05;
float Jump = 0.8f;
bool grounded = false;
bool space;
BoundingBox playerBox{};
Vector3 hitBox{};
float coolDown = 0;
vector<Bullet> entities = {};
Camera3D camera = {0};
Vector3 position = (Vector3){0,2,1};
Vector3 velocity = (Vector3){0,0,0};
Vector3 hitbox = (Vector3){1.0f,2.0f,1.0f};
bool alive = true;
int cameraMode = CAMERA_FIRST_PERSON;
};
struct outputState{
};
struct inputState{
};
class Player {
public:
Player(Vector3 temp_postion, Vector3 temp_velocity, Vector3 temp_hitbox1){
position = temp_postion;
velocity = temp_velocity;
hitbox = temp_hitbox1;
camera = {0};
camera.position = position;
camera.target = (Vector3){10.0f, 2.0f, 10.0f};
camera.up = (Vector3){ 0.0f, 1.0f, 0.0f };
camera.fovy = 60.0f; // Camera field-of-view Y
camera.projection = CAMERA_PERSPECTIVE;
alive = true;
JumpTimer = 0.0f;
playerBox = (BoundingBox){(Vector3){position.x - hitbox.x/2,
position.y - hitbox.y/2,
position.z - hitbox.z/2},
(Vector3){position.x + hitbox.x/2,
position.y + hitbox.y/2,
position.z + hitbox.z/2}};
// outputBuffer = CircularBuffer<outputState>(); //size needs to be tick rate * transmission time
//size needs to be max allowable rtt
};
bool CheckCollision(BoundingBox playerBB, BoundingBox wallBB, Vector3& separationVector);
void updateEntities(float dt);
Vector3 camera_direction(Camera *tcamera);
void UpdatePlayer(bool w, bool a, bool s, bool d,Vector2 mouseDelta,bool shoot,bool space,float dt,Vector3 prevPosition,vector<BoundingBox> &terrainList,vector<BoundingBox> &topBoxVector,bool sprint,bool crouch,PacketBuffer& outputBuffer);
Camera3D * getCamera();
Vector3 getHitBox();
void setCameraMode(int temp);
void setGrounded(bool temp,float dt);
bool getGrounded();
Vector3 getVelocity();
vector<Bullet>* getEntities();
Vector3 getPosition();
void startJumpTimer(float dt);
float getJumpTimer();
BoundingBox getPlayerBox();
void setPosition(Vector3 temp);
//
// CircularBuffer<outputState>* getOutputBuffer(){
// return &outputBuffer;
// }
// CircularBuffer<inputState>* getInputBuffer(){
// return &inputBuffer;
// }
private:
// CircularBuffer<outputState> outputBuffer;
// CircularBuffer<inputState> inputBuffer;
Vector3 separationVector{};
bool topCollision{};
float Gravity = -0.08;
float Jump = 2.5f;
bool grounded = false;
BoundingBox playerBox{};
float coolDown = 0;
vector<Bullet> entities = {};
Camera3D camera{};
Vector3 position{};
Vector3 velocity{};
Vector3 hitbox{};
bool alive;
float JumpTimer;
};