Barra de vida pro jogador
[Projeto-PCG.git] / player.cpp
blobca37d2677643380ac98f50060314d49646aa2d1a
1 #include "player.h"
2 #include "shot.h"
4 Player::Player(Game* agame, Ponto pos, Ponto speed): Shooter(agame, pos, speed) {
5 hp = MAXHP;
8 void Player::desenha() {
9 game->desenhaMira(aim);
10 Shooter::desenha();
13 void Player::collide(Thing *b) {
14 Shot* shot = dynamic_cast<Shot*>(b);
15 if (shot && shot->firedBy != this) {
16 shot->dead = true;
17 if (this->getPosition().x < shot->firedBy->getPosition().x)
18 addToAngle -= 0.5;
19 else
20 addToAngle += 0.5;
21 addToAngle = std::max(std::min(addToAngle, PI/2),-PI/2);
22 hp -= shot->damage;
23 if (hp <= 0) {
24 dead = true;