-
Notifications
You must be signed in to change notification settings - Fork 0
/
Player.cpp
88 lines (77 loc) · 2.66 KB
/
Player.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
//#include <cmath>
#include <GL/glut.h>
//#include "game.hpp"
#include "gl.hpp"
#include "Player.hpp"
#include "Triple.hpp"
//#define DEBUG_PLAYER
#ifdef DEBUG_PLAYER
# include <iostream>
#endif
Player::Player(const Player &p) {
this->name = p.name ;
this->pos = p.pos ;
this->ang = p.ang ;
this->vel = p.vel ;
this->vrot = p.vrot ;
control_f = p.control_f ;
control_b = p.control_b ;
control_l = p.control_l ;
control_r = p.control_r ;
control_rot_l = p.control_rot_l;
control_rot_r = p.control_rot_r;
control_jump = p.control_jump ;
control_shoot = p.control_shoot;
}
Player::Player(std::string name, Triple pos, double ang, Triple vel, double vrot):
RuntimePoint(name, pos, ang, vel, vrot),
control_f(false),
control_b(false),
control_l(false),
control_r(false),
control_rot_l(false),
control_rot_r(false),
control_jump(false),
control_shoot(false)
{}
void Player::steer(unsigned int ticks, unsigned int delta_ticks) {
/*
double pv = 0;
if (this->control_jump && this->pos.z == 0 && this->vel.z == 0) {
// TODO: use #define
this->vel.z = 0.04;
}
// TODO: convertir en Behavior "Fall"
if (this->pos.z != 0 || this->vel.z != 0) {
this->vel.z += GRAVEDAD * delta_ticks;
if (this->pos.z <= 0) {
this->pos.z = 0;
this->vel.z = 0;
}
} else {
if (control_f ) pv = delta_ticks / 10000.0;
if (control_b ) pv = -delta_ticks / 10000.0;
if (control_rot_l) this->vrot += delta_ticks / 5000.0;
if (control_rot_r) this->vrot -= delta_ticks / 5000.0;
// pv += -0.005 * pv * delta_ticks;
this->vel.x += pv * cos(this->ang);
this->vel.y += pv * sin(this->ang);
}
this->Actor::steer(delta_ticks);
*/
}
void Player::update() {}
void Player::draw() const {
glPushMatrix();
glColor4ub(0, 255, 0, 255);
glTranslatef(0, 0, 0.5);
glCallList(cubo);
glBegin(GL_LINES);
glVertex3f(0, 0, 0);
glVertex3f(2, 0, 0);
glEnd();
glPopMatrix();
#ifdef DEBUG_PLAYER
std::cout << "player: drawing at (" << pos.x << ", " << pos.y << ", " << pos.z << ")" << std::endl;
#endif
}