4 #include "shotmanager.h"
9 Shot::Shot(double x
, double y
, double angle
, double speed
, double gravity
, Weapon
* w
) {
13 game
->gravityManager
->subscribe(this);
14 game
->collisionManager
->subscribe(this);
15 gravityRate
= gravity
;
17 setSpeed(-cos(angle
)*speed
,sin(angle
)*speed
);
21 game
->shotManager
->deleteShot(this);
22 game
->collisionManager
->remove(this);
23 if (gravityRate
!= 0.0)
24 game
->gravityManager
->deleteThing(this);
27 void Shot::desenha() {
29 glTranslatef(getX(),getY(),0);
34 Polygon
Shot::getCollision() {
35 Ponto
atual(getX(),getY());
36 Polygon collisionSprite
= sprite
;
37 for (int i
= 0; i
< collisionSprite
.linhas
.size();i
++) {
38 collisionSprite
.linhas
[i
].vertices
[0] = collisionSprite
.linhas
[i
].vertices
[0] + atual
;
39 collisionSprite
.linhas
[i
].vertices
[1] = collisionSprite
.linhas
[i
].vertices
[1] + atual
;
41 return collisionSprite
;
46 void Shot::collide(Thing
* b
){
48 if (p
= dynamic_cast<Player
*>(b
)) {
49 std::cout
<<"Player deaded "<<p
<<std::endl
;