Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class ObjectData
- {
- private:
- //object position data
- GLfloat object_x;
- GLfloat object_y;
- //object draw data
- GLfloat object_width;
- GLfloat object_height;
- //object color data
- GLfloat object_cred;
- GLfloat object_cgreen;
- GLfloat object_cblue;
- //object information
- GLint object_mode;
- GLint object_ID;
- //this information will provide a good physics
- public:
- void CreateSquare
- (GLfloat color_red, GLfloat color_green, GLfloat color_blue, GLfloat o_x, GLfloat o_y, GLfloat o_width , GLfloat o_height)
- {
- GLint o_id = -1;
- o_id ++;
- glColor3f(color_red,color_green,color_blue); //we define the color of the object
- glBegin(GL_POLYGON); //creating a Polygon object
- glVertex2f(o_x,o_y); //origin point
- glVertex2f((o_x+o_width),o_y); //origin + width
- glVertex2f((o_x+o_width),(o_y+o_height)); //origin + width + height
- glVertex2f(o_x,(o_y+o_height)); //origin + height
- glEnd(); //just end the creation of the square
- object_cred = color_red; object_cgreen = color_green; object_cblue = color_blue; //setting the color information to the class
- object_x = o_x; object_y = o_y; object_width = o_width; object_height = o_height; //setting the postion information
- object_mode = GL_POLYGON;
- object_ID = o_id;
- }
- void UpdateObjectPosition()
- {
- glColor3f(object_cred,object_cgreen,object_cblue); //we define the color of the object
- glBegin(GL_POLYGON); //creating a Polygon object
- glVertex2f(object_x,object_y); //origin point
- glVertex2f((object_x+object_width),object_y); //origin + width
- glVertex2f((object_x+object_width),(object_y+object_height)); //origin + width + height
- glVertex2f(object_x,(object_y+object_height)); //origin + height
- glEnd(); //just end the creation of the square
- }
- void SetPosition(GLfloat oX, GLfloat oY)
- {
- object_x += oX; object_y += oY;
- }
- float GetObjectX(){ return object_x; }
- float GetObjectY(){ return object_y; }
- };
Advertisement
Add Comment
Please, Sign In to add comment