Thursday, April 26, 2012

Still working on the NewLine... it's boring...

GameMath.h is getting more complex than I original thought it would get.  I'm working on ways to make it faster and I'm adding functionality to Line. I may divide it into a separate .h/.cpp per class to make it a little more readable.

Here's what it looks like now.


 //GameMath.h  
 //designed to handle all the 2D math  
 //involved in making a 2D game engine.  
 //I may pull out stuff like the line   
 //and intPoint class as seperate .h/.cpp  
 //for readablilty. That will depend   
 //on how complex this thing gets  
 //intPoint CLASS :D  
 class intPoint  
 {  
 public:  
      //default constructor  
      intPoint();  
      //constructor for x/y  
      intPoint(int X, int Y);  
      //add two intPoints  
      intPoint operator+ (intPoint B);  
      intPoint operator+= (intPoint B);  
      //subtract two intPoints  
      intPoint operator- (intPoint B);  
      intPoint operator-= (intPoint B);  
      //multiply  
      intPoint operator* (float Mult);  
      intPoint operator/ (float Dev);  
      bool operator< ( intPoint input );  
      bool operator> ( intPoint input );  
      bool operator<= ( intPoint input );  
      bool operator>= ( intPoint input );  
      //these are public since there isn't really   
      //a point to making them private  
      int x;  
      int y;  
 };  
 //line class  
 class line  
 {  
      intPoint Org;  
      intPoint Dis;  
      float M;  
      float B;  
 public:  
      //Intersection Stuff  
      bool SlideTo( intPoint* OUTPUT , line CD );  
      bool IntersectIntPoint( intPoint* OUTPUT , line CD );  
      //Change Values  
      line Shift( intPoint ShiftBy ); //Shift the point of org by a value  
      line SetOrg( intPoint MoveTo ); //set a new point of org  
      line SetDis( intPoint NewEnd ); //set new endpoint  
      //get fuctions  
      intPoint GetOrg();  
      intPoint GetDis();  
      float GetM();  
      float GetB();  
      //Constructors  
      line( line LineWith , intPoint newSlope );  
      line( intPoint Origin , intPoint Displacement );  
      line(); //base constructor  
      void Draw();  
 };  
 //region  
 class Region  
 {  
 public:  
      bool InRegion( intPoint C );  
 };  
 class BoxRegion : public Region  
 {  
      intPoint Org;  
      intPoint Size;  
 public:  
      bool InRegion( intPoint C );  
      BoxRegion( intPoint Org , intPoint Size );  
      BoxRegion();  
 };  
 class CircleRegion : public Region  
 {  
      intPoint Org;  
      int SizeSquared;  
 public:  
      bool InRegion( intPoint C );  
      CircleRegion( intPoint CenterPoint , short unsigned int Size );  
      CircleRegion();  
 };  


No comments:

Post a Comment