Movement Class Reference

#include <Movement.h>

List of all members.

Public Member Functions

 Movement (int max)
Point move (int xpos, int ypos)
void createWaypoint ()

Private Attributes

Point waypoint
int max


Constructor & Destructor Documentation

Movement::Movement ( int  max  ) 

00019                           {
00020         this->waypoint.x = 0;
00021         this->waypoint.y = 0;
00022         this->max = max;
00023         createWaypoint();
00024 }


Member Function Documentation

Point Movement::move ( int  xpos,
int  ypos 
)

Function is called by GameClient with actual Player Position GameClient expects a Point with the new Location and reached = true when something special like a Waypoint was reached.

00031                                        {
00036         Point p;
00037         p.reached=false;
00038         p.x=xpos;
00039         p.y=ypos;
00040         
00041         // Move in x-direction of actual Waypoint:
00042         if( p.x - waypoint.x > 0 ) {
00043                 p.x = xpos + intuniform(-100,30);
00044         }
00045         else {
00046                 p.x = xpos + intuniform(-30,+100);
00047         }
00048         // Move in y-direction of actual Waypoint
00049         if( p.y - waypoint.y > 0 ) {
00050                 p.y = ypos + intuniform(-100,30);
00051         }
00052         else {
00053                 p.y = ypos + intuniform(-30,+100);
00054         }
00055         // Check Range / valid Output
00056         if(p.x < 0) p.x = 0;
00057         else if(p.x > max ) p.x = max;
00058         if(p.y < 0) p.y = 0;
00059         else if(p.y > max ) p.y = max;
00060         
00061         // Check if we are near of the actual waypoint:
00062         if ( abs( p.x - waypoint.x) < 50 ) p.x = waypoint.x;
00063         if ( abs( p.y - waypoint.y) < 50 ) p.y = waypoint.y;
00064         
00065         // Are we now at our Waypoint?
00066         if( p.x == waypoint.x && p.y == waypoint.y) {
00067                 p.reached = true; // Yes let it GameClient know..
00068                 createWaypoint(); // And create a new one
00069         }
00070         return p;
00071 }

void Movement::createWaypoint (  ) 

00026                               {
00027         waypoint.x = intuniform(0, max);
00028         waypoint.y = intuniform(0, max);
00029 }


Member Data Documentation

Point Movement::waypoint [private]

int Movement::max [private]


The documentation for this class was generated from the following files:
Generated on Thu Apr 17 13:19:29 2008 for ITM OverSim by  doxygen 1.5.3