Linhas mais espessas, anti-aliasing e pontos melhor definidos.
[Projeto-PCG.git] / player.cpp
blob330c545f88e76607b8e50a8accb28e9cd3190a2d
1 #include "player.h"
2 #include "gravity.h"
4 Player::Player(Game* agame) {
5 setPosition(40,40);
6 setSpeed(0,0);
7 game = agame;
8 game->gravityManager->subscribe(this);
11 Ponto Player::leftFeet() {
12 Ponto pe(-10,0);
13 return pe;
16 Ponto Player::rightFeet() {
17 Ponto pe(10,0);
18 return pe;
21 Ponto Player::leftArm() {
22 Ponto braco(-10,-30);
23 return braco;
26 Ponto Player::rightArm() {
27 Ponto braco(10,-30);
28 return braco;
31 Ponto Player::cintura() {
32 Ponto c(0,-30);
33 return c;
36 Ponto Player::pescoco() {
37 Ponto neck(0,-60);
38 return neck;
41 void Player::desenha() {
42 glPushMatrix();
43 glTranslatef(getX(),getY(),0);
44 Ponto leftfeet = leftFeet();
45 Ponto rightfeet = rightFeet();
46 Ponto hips = cintura();
47 Ponto leftarm = leftArm();
48 Ponto rightarm = rightArm();
49 Ponto neck = pescoco();
50 glBegin(GL_LINES);
51 glVertex3f(hips.x,hips.y,0);
52 glVertex3f(neck.x,neck.y,0);
54 glVertex3f(leftfeet.x,leftfeet.y,0);
55 glVertex3f(hips.x,hips.y,0);
57 glVertex3f(rightfeet.x,rightfeet.y,0);
58 glVertex3f(hips.x,hips.y,0);
60 glVertex3f(leftarm.x,leftarm.y,0);
61 glVertex3f(neck.x,neck.y,0);
63 glVertex3f(rightarm.x,rightarm.y,0);
64 glVertex3f(neck.x,neck.y,0);
65 glEnd();
66 glPushMatrix();
67 glTranslatef(neck.x,neck.y-10,0);
68 drawCircle(10,30);
69 glPopMatrix();
70 glPopMatrix();
74 Rect Player::getBaseRect() {
75 Ponto leftfeet = leftFeet();
76 Ponto rightfeet = rightFeet();
77 Rect ret(leftfeet.x+getX(),leftfeet.y+getY(),rightfeet.x+getX(),-10+getY()+std::min(leftfeet.y,rightfeet.y));
78 return ret;