5 Enemy::Enemy(Game
* agame
): Shooter(agame
, Ponto(0,0), Ponto(0,0)) {
11 //game->enemyManager->remove(this);
12 //game->gravityManager->deleteThing(this);
13 //game->collisionManager->remove(this);
16 double Enemy::distanceFromPlayer() {
17 return distance(game
->player
->getPosition(), this->getPosition());
21 addSpeed(closerToZero(-getSpeedX(),sign(getSpeedX())*-0.5),0);
24 Player
*player
= game
->player
;
25 Ponto playerpos
= player
->getPosition();
26 if (playerpos
.x
< getPosition().x
)
30 if (distanceFromPlayer() >= 500)
32 if (player
->crawl
&& onGround
)
34 if (playerpos
.y
> getPosition().y
+ 30 && distanceFromPlayer() <= 200)
38 if (playerpos
.y
< getPosition().y
&& player
->onGround
) {
41 if (distanceFromPlayer() <= 300 && distanceFromPlayer() >= 200)
42 addSpeed( direction
*3, 0);
43 Ponto leftfeet
= player
->leftFeet();
44 Ponto rightfeet
= player
->rightFeet();
45 setAim(playerpos
.x
+ player
->pescoco().x
,playerpos
.y
+player
->pescoco().y
+ std::min(-rightfeet
.y
,-leftfeet
.y
));
49 void Enemy::collide(Thing
* b
) {
51 Shot
* shot
= dynamic_cast<Shot
*>(b
);
52 if (shot
&& shot
->firedBy
== game
->player
) {
55 Shooter
* shooter
= dynamic_cast<Shooter
*>(b
);
57 if (shooter
->getPosition().x
> getPosition().x
)
64 void Enemy::drawEquipment() {
66 Ponto hip
= cintura();
67 Ponto leftfeet
= leftFeet();
68 Ponto rightfeet
= rightFeet();
69 glTranslatef(hip
.x
,hip
.y
,0);
70 glRotatef(bodyAngle
*180.0/PI
,0,0,1);
71 glBegin(GL_LINE_LOOP
);
74 glVertex3f(-10,-30,0);
77 glBegin(GL_LINE_LOOP
);