Player atingido por lanca chamas nao fica mais girando feito doido
[Projeto-PCG.git] / shot.cpp
blob1f6cf43c1591b983aeb2d8ba2b0239f3945fb549
1 #include "shot.h"
2 #include "weapon.h"
3 #include "game.h"
4 #include "shotmanager.h"
5 #include "collision.h"
6 #include "player.h"
7 #include "shooter.h"
8 #include "enemy.h"
9 #include <math.h>
11 Shot::Shot(double x, double y, double angle, double speed, double gravity, Weapon* w) {
12 game = w->game;
13 firedBy = w->firedBy;
14 setPosition(x,y);
15 if (gravity != 0.0)
16 game->gravityManager->subscribe(this);
17 game->collisionManager->subscribe(this);
18 gravityRate = gravity;
19 bypass = true;
20 setSpeed(-cos(angle)*speed,sin(angle)*speed);
23 Shot::~Shot() {
24 game->shotManager->deleteShot(this);
25 game->collisionManager->remove(this);
26 if (gravityRate != 0.0)
27 game->gravityManager->deleteThing(this);
30 void Shot::desenha() {
31 glPushMatrix();
32 glTranslatef(getX(),getY(),0);
33 sprite.desenha();
34 glPopMatrix();
37 Polygon Shot::getCollision() {
38 Polygon collisionSprite = sprite;
39 return collisionSprite;
42 void Shot::collide(Thing* b){
43 if (dead) return;
44 /*Player* p = dynamic_cast<Player*>(b);
46 Enemy* e = dynamic_cast<Enemy*>(b);
47 std::cout<<b<<std::endl;
48 if (p ) {
50 else if (e ) {
51 e->die();
53 }*/