Polecat Class Reference

#include <polecat.h>

Inheritance diagram for Polecat:

Inheritance graph
[legend]
Collaboration diagram for Polecat:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 Polecat (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
uint last_fart_time
double angle

Detailed Description

Definition at line 40 of file polecat.h.


Constructor & Destructor Documentation

Polecat::Polecat ( ExplosiveWeaponConfig cfg,
WeaponLauncher p_launcher 
)

Definition at line 46 of file polecat.cpp.

00047                                               :
00048   WeaponProjectile("polecat", cfg, p_launcher)
00049 {
00050   explode_with_collision = false;
00051   last_fart_time = 0;
00052 }


Member Function Documentation

void Polecat::Refresh (  )  [virtual]

Reimplemented from WeaponProjectile.

Definition at line 70 of file polecat.cpp.

00071 {
00072   WeaponProjectile::Refresh();
00073 
00074   double norme, angle;
00075   //When we hit the ground, jump !
00076   if(!IsMoving() && !FootsInVacuum())
00077   {
00078     //If the GNU is stuck in ground -> change direction
00079     int x = GetX();
00080     int y = GetY();
00081     if(x==save_x && y==save_y)
00082       m_sens = - m_sens;
00083     save_x = x;
00084     save_y = y;
00085 
00086     //Do the jump
00087     norme = randomSync.GetDouble(1.0, 2.0);
00088     PutOutOfGround();
00089     SetSpeedXY(Point2d(m_sens * norme , - norme * 3.0));
00090   }
00091   if (last_fart_time + TIME_BETWEEN_FART < Time::GetInstance()->Read()) {
00092     double norme = randomSync.GetLong(0, 5000)/100;
00093     double angle = randomSync.GetLong(0, 3000)/1000;
00094     ParticleEngine::AddNow(GetPosition(), 1, particle_POLECAT_FART, true, norme, angle);
00095     last_fart_time = Time::GetInstance()->Read();
00096   }
00097   //Due to a bug in the physic engine
00098   //sometimes, angle==infinite (according to gdb) ??
00099   GetSpeed(norme, angle);
00100 
00101   while(angle < -M_PI)
00102     angle += M_PI;
00103   while(angle > M_PI)
00104     angle -= M_PI;
00105 
00106   angle /= 2.0;
00107   if(m_sens == -1)
00108   {
00109     if(angle > 0)
00110       angle -= M_PI_2;
00111     else
00112       angle += M_PI_2;
00113   }
00114 
00115   image->SetRotation_rad(angle);
00116   image->Scale((double)m_sens,1.0);
00117   image->Update();
00118   // Set the test area ?
00119   SetTestRect ( image->GetWidth()/2-1,
00120                 image->GetWidth()/2-1,
00121                 image->GetHeight()/2-1,
00122                 image->GetHeight()/2-1);
00123 }

Here is the call graph for this function:

void Polecat::Shoot ( double  strength  )  [virtual]

Reimplemented from WeaponProjectile.

Definition at line 54 of file polecat.cpp.

00055 {
00056   WeaponProjectile::Shoot(strength);
00057   last_fart_time = Time::GetInstance()->Read() + TIME_BETWEEN_FART;
00058 
00059   save_x=GetX();
00060   save_y=GetY();
00061 
00062   double angle = ActiveCharacter().GetFiringAngle();
00063 
00064   if(angle<M_PI/2 && angle>-M_PI/2)
00065     m_sens = 1;
00066   else
00067     m_sens = -1;
00068 }

Here is the call graph for this function:

void Polecat::SignalOutOfMap (  )  [protected, virtual]

Reimplemented from WeaponProjectile.

Definition at line 125 of file polecat.cpp.

00126 {
00127   GameMessages::GetInstance()->Add (_("The Polecat left the battlefield before exploding"));
00128   WeaponProjectile::SignalOutOfMap();
00129 }

Here is the call graph for this function:


Member Data Documentation

double Polecat::angle [private]

Definition at line 46 of file polecat.h.

uint Polecat::last_fart_time [private]

Definition at line 45 of file polecat.h.

int Polecat::m_sens [private]

Definition at line 43 of file polecat.h.

int Polecat::save_x [private]

Definition at line 44 of file polecat.h.

int Polecat::save_y [private]

Definition at line 44 of file polecat.h.


The documentation for this class was generated from the following files:
Generated on Mon Jan 1 14:11:04 2007 for Wormux by  doxygen 1.4.7