-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathPlayer.cpp
More file actions
61 lines (57 loc) · 1.8 KB
/
Player.cpp
File metadata and controls
61 lines (57 loc) · 1.8 KB
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
#include "Player.h"
#include <math.h>
Player::Player(std::deque<Point>::reverse_iterator tp) : controls({sf::Keyboard::W,
sf::Keyboard::S,
sf::Keyboard::A,
sf::Keyboard::D,
sf::Keyboard::Up,
sf::Keyboard::Down,
sf::Keyboard::Left,
sf::Keyboard::Right,}),
tp(tp)
{
score = 0;
geo_size = 3;
geo = new Poly[geo_size];
/*
geo[0] = Point(50, 0, 0);
geo[1] = Point(0, 50, 0);
geo[2] = Point(0, 0, 0);
*/
geo[0] = Poly(Point(-0.75, -1, 0),
Point(0, 1, 0),
Point(0, -0.5, 0.75),
Point(-1, 0, 0),
0, 1, 1, 1);
geo[1] = Poly(Point(0.75, -1, 0),
Point(0, 1, 0),
Point(0, -0.5, 0.75),
Point(1, 0, 0),
0, 1, 1, 1);
geo[2] = Poly(Point(-0.75, -1, 0),
Point(0.75, -1, 0),
Point(0, -0.5, 0.75),
Point(0, -1, 0),
1, 1, 0, 1);
}
float Player::trackDist(std::deque<Point>::reverse_iterator trackp) {
// The smallest distance to the track piece provided by the iterator.
return sqrt(pow((trackp->x - r.x),2) + pow((trackp->y - r.y),2) + pow((trackp->z - r.z),2));
}
void Player::Render(float elapsedTime) {
Object::Render(elapsedTime);
while ( trackDist(tp+1) < trackDist(tp)) {
//std::cout << "In while" << std::endl;
double temp = 10 - trackDist(tp);
if (temp < 0)
{
temp = 0;
}
score += temp*temp;
tp++;
}
}
Camera::Camera(Point pos, Point rot) {
r = pos;
rr = rot;
}