BlueX

objectmover

Mar 24th, 2013
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.94 KB | None | 0 0
  1. class ObjectData
  2. {
  3. private:
  4.     //object position data
  5.     GLfloat object_x;
  6.     GLfloat object_y;
  7.  
  8.     //object draw data
  9.     GLfloat object_width;
  10.     GLfloat object_height;
  11.  
  12.     //object color data
  13.     GLfloat object_cred;
  14.     GLfloat object_cgreen;
  15.     GLfloat object_cblue;
  16.    
  17.     //object information
  18.     GLint object_mode;
  19.     GLint object_ID;
  20.  
  21.     //this information will provide a good physics
  22. public:
  23.    
  24.     void CreateSquare
  25.         (GLfloat color_red, GLfloat color_green, GLfloat color_blue, GLfloat o_x, GLfloat o_y,  GLfloat o_width , GLfloat o_height)
  26.     {
  27.         GLint o_id = -1;
  28.         o_id ++;
  29.  
  30.         glColor3f(color_red,color_green,color_blue); //we define the color of the object
  31.         glBegin(GL_POLYGON); //creating a Polygon object
  32.             glVertex2f(o_x,o_y); //origin point
  33.             glVertex2f((o_x+o_width),o_y); //origin + width
  34.             glVertex2f((o_x+o_width),(o_y+o_height)); //origin + width + height
  35.             glVertex2f(o_x,(o_y+o_height)); //origin + height
  36.         glEnd(); //just end the creation of the square
  37.  
  38.         object_cred = color_red; object_cgreen = color_green; object_cblue = color_blue; //setting the color information to the class
  39.  
  40.         object_x = o_x; object_y = o_y; object_width = o_width; object_height = o_height; //setting the postion information
  41.        
  42.         object_mode = GL_POLYGON;
  43.         object_ID = o_id;
  44.  
  45.     }
  46.  
  47.     void UpdateObjectPosition()
  48.     {
  49.         glColor3f(object_cred,object_cgreen,object_cblue); //we define the color of the object
  50.         glBegin(GL_POLYGON); //creating a Polygon object
  51.             glVertex2f(object_x,object_y); //origin point
  52.             glVertex2f((object_x+object_width),object_y); //origin + width
  53.             glVertex2f((object_x+object_width),(object_y+object_height)); //origin + width + height
  54.             glVertex2f(object_x,(object_y+object_height)); //origin + height
  55.         glEnd(); //just end the creation of the square
  56.     }
  57.  
  58.     void SetPosition(GLfloat oX, GLfloat oY)
  59.     {
  60.         object_x += oX; object_y += oY;
  61.        
  62.     }
  63.  
  64.     float GetObjectX(){ return object_x; }
  65.     float GetObjectY(){ return object_y; }
  66.  
  67. };
Advertisement
Add Comment
Please, Sign In to add comment