-
Notifications
You must be signed in to change notification settings - Fork 0
/
Player.h
115 lines (85 loc) · 2.1 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
113
114
115
//
// Created by flo on 10/28/2021.
//
#ifndef NOMPROJET_PLAYER_H
#define NOMPROJET_PLAYER_H
#include<iostream>
using namespace std;
class Player{
private:
float x=0.0F,y=0.0F;
float dirX=0.0F,dirY=0.0F;
float speed = 0.38F;
bool playing = false;
pair<float,float> spawn = {0.0f,0.0f};
bool isInsideRoom = false;
bool lightOn=true;
int vision_ray = 10;
const int MIN_VISION_RAY = 0;
const int MAX_VISION_RAY = 20;
public:
float getX(){return x;}
float getY(){return y;}
float getDirX(){return dirX;}
float getDirY(){return dirY;}
float getSpeed(){return speed;}
bool isPlaying(){return playing;}
bool start(){playing = true;}
bool lose(){playing = false;}
bool insideRoom(){return isInsideRoom;}
void setOnRoom(bool insideRoom){isInsideRoom=insideRoom;}
void setSpeed(float speed){
this->speed = speed;
}
void move(float offSetX,float offSetY){
moveX(offSetX);
moveY(offSetY);
}
void setPos(float x,float y){
setX(x);
setY(y);
}
void moveX(float offSet){
x += (offSet * speed);
}
void moveY(float offSet){
y += (offSet * speed);
}
void setX(float x){
this->x =x;
}
void setY(float y){
this->y = y;
}
void cleanDir(){
dirX = 0.0F;
dirY = 0.0F;
}
void incDir(float offSetX,float offSetY){
dirX += offSetX;
dirY += offSetY;
}
void incRay(int incDelta){
vision_ray+=incDelta;
vision_ray=min(MAX_VISION_RAY,vision_ray);
vision_ray=max(vision_ray,MIN_VISION_RAY);
}
int getVisionRay(){
return vision_ray;
}
void setSpawn(float x,float y){
spawn = {x,y};
}
void setSpawn(std::pair<float,float> spawns){
spawn = spawns;
}
void respawn(){
x=spawn.first;
y=spawn.second;
}
void setDirY(float setY){dirY = setY;}
void setDirX(float setX){dirX = setX;}
void switchLight(){lightOn=!lightOn;}
bool isLightOn(){return lightOn;}
};
#endif //NOMPROJET_PLAYER_H