#include <gnu.h>
Inheritance diagram for Gnu:
Public Member Functions | |
Gnu (ExplosiveWeaponConfig &cfg, WeaponLauncher *p_launcher) | |
void | Shoot (double strength) |
void | Refresh () |
Protected Member Functions | |
void | SignalOutOfMap () |
Private Attributes | |
int | m_sens |
int | save_x |
int | save_y |
Definition at line 36 of file gnu.h.
Gnu::Gnu | ( | ExplosiveWeaponConfig & | cfg, | |
WeaponLauncher * | p_launcher | |||
) |
Definition at line 37 of file gnu.cpp.
00038 : 00039 WeaponProjectile("gnu", cfg, p_launcher) 00040 { 00041 explode_with_collision = false; 00042 }
void Gnu::Refresh | ( | ) | [virtual] |
Reimplemented from WeaponProjectile.
Definition at line 59 of file gnu.cpp.
00060 { 00061 WeaponProjectile::Refresh(); 00062 00063 double norme, angle; 00064 //When we hit the ground, jump ! 00065 if(!IsMoving()&& !FootsInVacuum()) 00066 { 00067 //If the GNU is stuck in ground -> change direction 00068 int x = GetX(); 00069 int y = GetY(); 00070 if(x==save_x && y==save_y) 00071 m_sens = - m_sens; 00072 save_x = x; 00073 save_y = y; 00074 00075 //Do the jump 00076 norme = randomSync.GetDouble(2.0, 5.0); 00077 PutOutOfGround(); 00078 SetSpeedXY(Point2d(m_sens * norme , - norme * 3.0)); 00079 } 00080 00081 //Due to a bug in the physic engine 00082 //sometimes, angle==infinite (according to gdb) ?? 00083 GetSpeed(norme, angle); 00084 00085 while(angle < -M_PI) 00086 angle += M_PI; 00087 while(angle > M_PI) 00088 angle -= M_PI; 00089 00090 angle /= 2.0; 00091 if(m_sens == -1) 00092 { 00093 if(angle > 0) 00094 angle -= M_PI_2; 00095 else 00096 angle += M_PI_2; 00097 } 00098 00099 if(angle > 4 * M_PI) 00100 angle = 0; 00101 00102 image->SetRotation_rad(angle); 00103 image->Scale((double)m_sens,1.0); 00104 image->Update(); 00105 // Fixe le rectangle de test ?? 00106 SetTestRect ( image->GetWidth()/2-1, 00107 image->GetWidth()/2-1, 00108 image->GetHeight()/2-1, 00109 image->GetHeight()/2-1); 00110 }
Here is the call graph for this function:
void Gnu::Shoot | ( | double | strength | ) | [virtual] |
Reimplemented from WeaponProjectile.
Definition at line 44 of file gnu.cpp.
00045 { 00046 WeaponProjectile::Shoot(strength); 00047 00048 save_x=GetX(); 00049 save_y=GetY(); 00050 00051 double angle = ActiveCharacter().GetFiringAngle(); 00052 00053 if(angle<M_PI/2 && angle>-M_PI/2) 00054 m_sens = 1; 00055 else 00056 m_sens = -1; 00057 }
Here is the call graph for this function:
void Gnu::SignalOutOfMap | ( | ) | [protected, virtual] |
Reimplemented from WeaponProjectile.
Definition at line 112 of file gnu.cpp.
00113 { 00114 GameMessages::GetInstance()->Add (_("The Gnu left the battlefield before exploding")); 00115 WeaponProjectile::SignalOutOfMap(); 00116 }
Here is the call graph for this function:
int Gnu::m_sens [private] |
int Gnu::save_x [private] |
int Gnu::save_y [private] |