src/character/move.h File Reference

#include "character.h"
#include "../object/physical_obj.h"

Include dependency graph for move.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

bool ComputeHeightMovement (Character &character, int &height, bool falling)
void MoveCharacter (Character &character)
void MoveCharacterRight (Character &character)
void MoveCharacterLeft (Character &character)
void SendCharacterPosition ()

Variables

const uint PAUSE_MOVEMENT = 30


Function Documentation

bool ComputeHeightMovement ( Character character,
int &  height,
bool  falling 
)

Definition at line 46 of file move.cpp.

00048 {
00049   int y_floor=character.GetY();
00050 
00051   if( character.IsInVacuum( Point2i(character.GetDirection(), 0))
00052   && !character.IsInVacuum( Point2i(character.GetDirection(), +1)) ){
00053     //Land is flat, we can move!
00054     height = 0;
00055     return true;
00056   }
00057 
00058   //Compute height of the step:
00059   if( character.IsInVacuum( Point2i(character.GetDirection(), 0)) ){
00060     //Try to go down:
00061     for(height = 2; height <= MAX_FALLING_HEIGHT ; height++){
00062       if( !character.IsInVacuum(Point2i(character.GetDirection(), height))
00063       ||  character.FootsOnFloor(y_floor+height)){
00064         height--;
00065         return true;
00066       }
00067     }
00068     //We can go down, but the step is to big -> the character will fall.
00069     if (falling) {
00070       character.SetX (character.GetX() +character.GetDirection());
00071       character.UpdatePosition();
00072       character.SetMovement("fall");
00073     }
00074     return false;
00075   }
00076   else{
00077     //Try to go up:
00078     for(height = -1; height >= -MAX_CLIMBING_HEIGHT ; height--)
00079       if( character.IsInVacuum( Point2i(character.GetDirection(), height) ) )
00080         return true;
00081   }
00082   //We can't move!
00083   return false;
00084 }

Here is the call graph for this function:

Here is the caller graph for this function:

void MoveCharacter ( Character character  ) 

Definition at line 87 of file move.cpp.

00088 {
00089   int height;
00090   bool fantome;
00091 
00092   // On est bien dans le monde ? (sinon, pas besoin de tester !)
00093   if (character.GetDirection() == -1)
00094     fantome = character.IsOutsideWorld ( Point2i(-1, 0) );
00095   else
00096     fantome = character.IsOutsideWorld ( Point2i(1, 0) );
00097   if (fantome){
00098     MSG_DEBUG("ghost", "%s will be a ghost.", character.GetName().c_str());
00099     character.Ghost();
00100     return;
00101   }
00102 
00103   // Calcule la hauteur a descendre
00104   if (!ComputeHeightMovement (character, height, true)) return;
00105 
00106   do
00107   {
00108     // Bouge !
00109     GameLoop::GetInstance()->character_already_chosen = true;
00110     // Deplace enfin le character
00111 
00112     character.SetXY( Point2i(character.GetX() +character.GetDirection(),
00113                              character.GetY() +height) );
00114 
00115     // Gravite (s'il n'y a pas eu de collision
00116     character.UpdatePosition();
00117 
00118   }while(character.CanStillMoveDG(PAUSE_MOVEMENT) && ComputeHeightMovement (character, height, true));
00119 }

Here is the call graph for this function:

Here is the caller graph for this function:

void MoveCharacterLeft ( Character character  ) 

Definition at line 121 of file move.cpp.

00121                                             {
00122   // Le character est pret a bouger ?
00123   if (!character.MouvementDG_Autorise()) return;
00124 
00125   bool bouge = (character.GetDirection() == -1);
00126   if (bouge)
00127   {
00128     MoveCharacter(character);
00129   }
00130   else{
00131     ActionHandler::GetInstance()->NewAction(new Action(Action::ACTION_SET_CHARACTER_DIRECTION,-1));
00132     character.InitMouvementDG (PAUSE_CHG_DIRECTION);
00133   }
00134 
00135   //Refresh skin position across network
00136   if( !network.IsLocal() && (ActiveTeam().IsLocal() || ActiveTeam().IsLocalAI()))
00137     SendCharacterPosition();
00138 }

Here is the call graph for this function:

Here is the caller graph for this function:

void MoveCharacterRight ( Character character  ) 

Definition at line 141 of file move.cpp.

00142 {
00143   // Le character est pret a bouger ?
00144   if (!character.MouvementDG_Autorise()) return;
00145 
00146   bool bouge = (character.GetDirection() == 1);
00147   if (bouge)
00148   {
00149     MoveCharacter(character);
00150   }
00151   else
00152   {
00153     ActionHandler::GetInstance()->NewAction(new Action(Action::ACTION_SET_CHARACTER_DIRECTION,1));
00154     character.InitMouvementDG (PAUSE_CHG_DIRECTION);
00155   }
00156 
00157 
00158   //Refresh skin position across network
00159   if( !network.IsLocal() && ActiveTeam().IsLocal())
00160     SendCharacterPosition();
00161 }

Here is the call graph for this function:

Here is the caller graph for this function:

void SendCharacterPosition (  ) 

Definition at line 163 of file move.cpp.

00164 {
00165   assert(ActiveTeam().IsLocal() || ActiveTeam().IsLocalAI());
00166   Action* a = BuildActionSendCharacterPhysics(ActiveCharacter().GetTeamIndex(), ActiveCharacter().GetCharacterIndex());
00167   network.SendAction(a);
00168   delete a;
00169 
00170   Action a_set_skin(Action::ACTION_SET_SKIN,ActiveCharacter().body->GetClothe());
00171   a_set_skin.Push(ActiveCharacter().body->GetMovement());
00172   a_set_skin.Push((int)ActiveCharacter().body->GetFrame());
00173   network.SendAction(&a_set_skin);
00174 }

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

const uint PAUSE_MOVEMENT = 30

Definition at line 29 of file move.h.


Generated on Mon Jan 1 13:12:32 2007 for Wormux by  doxygen 1.4.7