Uhg my pong code I scavenged from the forums quickly went from 6 simple source files to 18 files total including headers.
This is a discussion on So... Spent another year or so without a computer. within the Game Programming forums, part of the General Programming Boards category; Uhg my pong code I scavenged from the forums quickly went from 6 simple source files to 18 files total ...
Uhg my pong code I scavenged from the forums quickly went from 6 simple source files to 18 files total including headers.
Sometimes I forget what I am doing when I enter a room, actually, quite often.
UPDATE:
Managed to abstract the ball and paddle classes into the "Renderable_Object" class.
Which now allows me to centralize the rendering process, like so!Code:#ifndef RENDERABLE_OBJECT_H #define RENDERABLE_OBJECT_H #include "Vector2.h" class Renderable_Object { public: Vector2 & getVelocity() { return velocity; } Vector2 & getPosition() { return position; } Vector2 & getMinimum() { return d_min; } Vector2 & getMaximum() { return d_max; } private: Vector2 position; Vector2 velocity; Vector2 d_min; Vector2 d_max; bool isPhysical; bool isVisible; }; #endif
I just eliminated 4 useless files and 2 classes! HURRAH!Code:#include "Renderable_Object.h" class Renderer { void draw(Renderable_Object object) { glPushMatrix(); glTranslatef(object.getPosition().x,object.getPosition().y,-50.0f); glBegin(GL_QUADS); // Start Drawing Quads glVertex3f(object.getMinimum().x, object.getMinimum().y, 1.0f); // Bottom Left Of The Texture and Quad glVertex3f( object.getMaximum().x, object.getMinimum().y, 1.0f); // Bottom Right Of The Texture and Quad glVertex3f( object.getMaximum().x, object.getMaximum().y, 1.0f); // Top Right Of The Texture and Quad glVertex3f(object.getMinimum().x, object.getMaximum().y, 1.0f); // Top Left Of The Texture and Quad glEnd(); glPopMatrix(); } };
Sometimes I forget what I am doing when I enter a room, actually, quite often.