So... Spent another year or so without a computer.

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 ...

  1. #16
    Absent Minded Programmer
    Join Date
    May 2005
    Posts
    964
    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.

  2. #17
    Absent Minded Programmer
    Join Date
    May 2005
    Posts
    964
    UPDATE:

    Managed to abstract the ball and paddle classes into the "Renderable_Object" class.

    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
    Which now allows me to centralize the rendering process, like so!

    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();
    	}
    };
    I just eliminated 4 useless files and 2 classes! HURRAH!
    Sometimes I forget what I am doing when I enter a room, actually, quite often.

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Constructive criticism/suggestions
    By LineOFire in forum C Programming
    Replies: 11
    Last Post: 09-30-2006, 09:32 AM
  2. Help with leap year program.
    By IxTanGxI in forum C Programming
    Replies: 8
    Last Post: 02-20-2006, 07:49 PM
  3. Major Computer Problem
    By Olidivera in forum Tech Board
    Replies: 10
    Last Post: 07-15-2005, 11:15 AM
  4. My New Computer?
    By Speedy5 in forum A Brief History of Cprogramming.com
    Replies: 24
    Last Post: 04-22-2003, 08:33 PM
  5. Help Me Out!! Pls
    By Joanna in forum C++ Programming
    Replies: 5
    Last Post: 10-27-2001, 05:08 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21