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();  
 };  


Wednesday, April 25, 2012

I was REALLY bored... so I wrote TheMemoryEater1000


I haven't posted anything in a while, so here is The Memory Eater: 1000. All it does it eat memory until it crashes... cuz yeah... why not. The 2000 version might have more features, but hopefully I won't be so bored I have to write it.

 //THE MEMORY EATER: 1000  
 #include <iostream>  
 using namespace std;  
 void CreateDumbMemory( int INPUT )  
 {  
      int KBToEat = INPUT * 1024;  
      for(int x = 0; x < KBToEat ; x++ )  
      {  
           new char[1024];  
      }  
      cout << "OMNOMNOM! (ate " << INPUT << "meg)\n";  
 }  
 void main()  
 {  
      int INPUT;  
      cout << "I am the Memory Eater 5000!\n\n";  
      do  
      {  
           cout << "Please Enter (in MegaBytes)\n"   
                "how more memory I should eat?\n:";  
           cin >> INPUT;  
           CreateDumbMemory( INPUT );  
      }while(INPUT);  
 }  

Wednesday, April 11, 2012

I had two seconds, so I made an update

Lately I've been extremely busy and it's been a full week since the last time I posted an update, so I figured I'd post this saying that I haven't given up on this, I just have no time between helping with Minecraft, TX and school.

THIS IS STILL A THING!, I've just too busy to doing things lately. I'll be back! I'll finish the new Line class this weekend!

Thursday, April 5, 2012

New "line" class

Prototype for new "line" class.

 class line  
 {  

      intPoint Org;  
      intPoint Dis;  
      float M;  

 public:  

      //Intersection Stuff  
      bool SlideTo( intPoint* OUTPUT , line CD );  
      bool IntersectPoint( intPoint* OUTPUT , line CD );  

      //change values  
      void Shift( intPoint ShiftBy );  
      void SetOrg( intPoint MoveTo );  
      void SetDis( intPoint NewEnd );  

      //Constructors  
      line( line LineWith , intPoint newSlope );  
      line( intPoint Origin , intPoint Displacement );  

      //Draw!  
      void Draw();  

 };  

This new version has two primary changes.

  • I added a float for the slope (M).
  • I converted the definition to be a point relative to the Origin and a Displacement relative to the first point.

I did both of these (and created the new constructors) to make polygon collision faster. My method of detecting if two polygons collide is based on drawing a line from each point of polygon A that represent the displacement, then you detect if those lines intersect with any line of polygon B. This means you are calculating the same slope (each displacement line) several times. If you make slope part of the line and build constructors that let you shift the point of origin you only have to calculate the slope once.

It doesn't make it easier, but it does make it faster. (I still don't know, however, if "faster" will even be relevant)

(ohyeah, and renamed Point to be intPoint because I might make a floatPoint someday)

Wednesday, April 4, 2012

Priorities

Ok, so I really need to figure out what I need to do next. SO, Imma make a simple billeted list of things to do with witch I will sort by priority!

HERE WE GO:
  • redesign Line class (HIGH priority)
  • Boxes (after LineClass)
  • Polygons (more complex Box)
  • Polygon Collision (fiction in Polygon)
  • Sliding  collision (use of Line Class for sliding collision)
  • Jumping Box "Game"! (use all that BS above to build a SUPER simple side scrolled)
EVENTUALLY: (maybe now, maybe later?)
  • Build a full render system (work queues, window placements, zoom, pan, sprite handling)  (meh)
  • Build a concept render system (window placement, zoom, pan)! (will make the thing above easier and make porting to a new engine easier [AGK] )
  • switch to APK (gawgawgw)
The "eventually" stuff can be done at any point, but I'm going to procrastinate and push it way back... except maybe the "Concept Render System" (haven't decided on that yet).

edit:
also, I might might clone Tetris... but I don't think that will be my test tools for the Render System thingies.