Adicionado uma bola onde o mouse esta, futura mira
[Projeto-PCG.git] / player.cpp
blobf951d20b6766f92e09dd55e7eec19d2f81ca3b41
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 game->desenhaMira(aim);
43 glPushMatrix();
44 glTranslatef(getX(),getY(),0);
45 Ponto leftfeet = leftFeet();
46 Ponto rightfeet = rightFeet();
47 Ponto hips = cintura();
48 Ponto leftarm = leftArm();
49 Ponto rightarm = rightArm();
50 Ponto neck = pescoco();
51 glBegin(GL_LINES);
52 glVertex3f(hips.x,hips.y,0);
53 glVertex3f(neck.x,neck.y,0);
55 glVertex3f(leftfeet.x,leftfeet.y,0);
56 glVertex3f(hips.x,hips.y,0);
58 glVertex3f(rightfeet.x,rightfeet.y,0);
59 glVertex3f(hips.x,hips.y,0);
61 glVertex3f(leftarm.x,leftarm.y,0);
62 glVertex3f(neck.x,neck.y,0);
64 glVertex3f(rightarm.x,rightarm.y,0);
65 glVertex3f(neck.x,neck.y,0);
66 glEnd();
67 glPushMatrix();
68 glTranslatef(neck.x,neck.y-10,0);
69 drawCircle(10,30);
70 glPopMatrix();
71 glPopMatrix();
75 Linha Player::getBaseLine() {
76 Ponto leftfeet = leftFeet();
77 Ponto rightfeet = rightFeet();
78 Linha ret(leftfeet.x+getX(),leftfeet.y+getY(),rightfeet.x+getX(),rightfeet.y+getY());
79 return ret;
82 void Player::setAim(double x, double y) {
83 aim.x = x;
84 aim.y = y;