-
Notifications
You must be signed in to change notification settings - Fork 1
/
Paddle.cpp
68 lines (55 loc) · 1.42 KB
/
Paddle.cpp
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
#include "Paddle.h"
Paddle::Paddle(glm::vec3 pos, float radDisk, float radPaddle, float widthTab, float lengthTab,float speedP)
{
posPaddle = pos;
radiusDisk = radDisk;
radius = radPaddle;
widthT = widthTab;
lengthT = lengthTab;
speed = speedP;
}
glm::vec3 Paddle::getPos() {
return posPaddle;
}
void Paddle::setPos(glm::vec3 pos) {
posPaddle = pos;
}
void Paddle::updatespeed(int check,float T) {
if (check == 1) {
if (speed > 0.6)
speed -= 0.5 * T;
return;
}
if (speed < 1.75)
speed += 0.5 * T;
return;
}
void Paddle::updatePaddle(float deltaT, float mx, float mz) {
/*
if (posPaddle.x + radius + mx * deltaT / speed <= 0.0 &&
posPaddle.x - radius + mx * deltaT / speed >= -lengthT/2)
*/
if (posPaddle.x < 0) {
if (posPaddle.x + radius + mx * deltaT / speed <= 0.0){
posPaddle.x += mx * deltaT / speed;
}
posPaddle.z -= mz * deltaT / speed;
}
else {
if (posPaddle.x - radius + mx * deltaT / speed >= 0.0) {
posPaddle.x += mx * deltaT / speed;
}
posPaddle.z -= mz * deltaT / speed;
}
/*
if (posPaddle.z + radius - mz * deltaT / speed <= widthT/2 &&
posPaddle.z - radius - mz * deltaT / speed >= -widthT/2)
*/
}
glm::vec3 Paddle::getNextPos(float deltaT, float mx, float mz) {
glm::vec3 nextPosPaddle = glm::vec3(posPaddle.x + mx * deltaT / speed,0.0f, posPaddle.z - mz * deltaT / speed);
return nextPosPaddle;
}
void Paddle::setSpeed(float speedP) {
speed = speedP;
}