WindParticle Class Reference

#include <wind.h>

Inheritance diagram for WindParticle:

Inheritance graph
[legend]
Collaboration diagram for WindParticle:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 WindParticle (std::string &xml_file)
 WindParticle (const WindParticle &aparticle)
 ~WindParticle ()
void Resize (double size)
void Draw ()
void Refresh ()

Public Attributes

Spritesprite

Detailed Description

Definition at line 34 of file wind.h.


Constructor & Destructor Documentation

WindParticle::WindParticle ( std::string &  xml_file  ) 

Definition at line 44 of file wind.cpp.

00044                                               :
00045   PhysicalObj("wind",xml_file)
00046 {
00047   SetCollisionModel(true, false, false);
00048 
00049   sprite = resource_manager.LoadSprite( ActiveMap().ResProfile(), "wind_particle");
00050 //  if(sprite->GetFrameCount()==1)
00051 //    sprite->cache.EnableLastFrameCache();
00052   sprite->SetCurrentFrame ( randomObj.GetLong(0, sprite->GetFrameCount()-1));
00053 
00054   double mass, wind_factor ;
00055 
00056   //Mass = mass_mean + or - 25%
00057   mass = GetMass();
00058   mass *= (1.0 + randomObj.GetLong(-100, 100)/400.0);
00059   SetMass (mass);
00060   SetSize( sprite->GetSize() );
00061   wind_factor = GetWindFactor() ;
00062   wind_factor *= (1.0 + randomObj.GetLong(-100, 100)/400.0);
00063   SetWindFactor(wind_factor);
00064   StartMoving();
00065   SetAirResistFactor(GetAirResistFactor() * (1.0 + randomObj.GetLong(-100, 100)/400.0));
00066 
00067   // Fixe le rectangle de test
00068   int dx = 0 ;
00069   int dy = 0 ;
00070   SetTestRect (dx, dx, dy, dy);
00071 
00072   m_allow_negative_y = true;
00073 }

Here is the call graph for this function:

WindParticle::WindParticle ( const WindParticle aparticle  )  [inline]

Definition at line 41 of file wind.h.

00041                                                      :
00042     PhysicalObj(aparticle)
00043     {
00044       assert(aparticle.sprite);
00045       sprite = new Sprite(*aparticle.sprite);
00046     };
  ~WindParticle() { delete sprite; };

WindParticle::~WindParticle (  )  [inline]

Definition at line 47 of file wind.h.

00047 { delete sprite; };


Member Function Documentation

void WindParticle::Draw (  )  [virtual]

Implements PhysicalObj.

Definition at line 120 of file wind.cpp.

00121 {
00122   sprite->Draw(GetPosition());
00123 }

Here is the call graph for this function:

void WindParticle::Refresh (  )  [virtual]

Implements PhysicalObj.

Definition at line 75 of file wind.cpp.

00076 {
00077   sprite->Update();
00078   UpdatePosition();
00079 
00080   // Flip the sprite if needed and if the direction of wind changed
00081   if(ActiveMap().wind.need_flip)
00082   {
00083     Point2d speed;
00084     GetSpeedXY(speed);
00085     float scale_x, scale_y;
00086     sprite->GetScaleFactors( scale_x, scale_y);
00087     if((speed.x<0 && scale_x>0)
00088     || (speed.x>0 && scale_x<0))
00089     {
00090       scale_x=-scale_x;
00091       sprite->Scale( scale_x, scale_y);
00092     }
00093   }
00094   // Put particles inside of the camera view
00095   // (there is no point in computing particle out of the camera!)
00096   int x = GetX();
00097   int y = GetY();
00098 
00099   if(GetX() > camera.GetPositionX() + camera.GetSizeX())
00100     x = camera.GetPositionX() - GetWidth() + 1;
00101 
00102   if(GetX() + GetWidth() < camera.GetPositionX() )
00103     x = camera.GetPositionX() + camera.GetSizeX() - 1;
00104 
00105   if(GetY() > camera.GetPositionY() + camera.GetSizeY())
00106     y = camera.GetPositionY() - GetHeight() + 1;
00107 
00108   if(GetY() + GetHeight() < camera.GetPositionY() )
00109     y = camera.GetPositionY() + camera.GetSizeY() - 1;
00110 
00111   m_alive = ALIVE;
00112 
00113   if(x!=GetX() || y!=GetY())
00114   {
00115     StartMoving();
00116     SetXY( Point2i(x, y) );
00117   }
00118 }

Here is the call graph for this function:

void WindParticle::Resize ( double  size  ) 

Definition at line 125 of file wind.cpp.

00126 {
00127   size=0.5+size/2.0;
00128   sprite->Scale( size,size);
00129   sprite->SetAlpha( size);
00130 }

Here is the call graph for this function:


Member Data Documentation

Sprite* WindParticle::sprite

Definition at line 37 of file wind.h.


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