My breakout game now has a moving paddle and I have been thinking about how to implement the collision detection. After looking at the tutorials on gametutorial.com I came across an easyish approach.
However now I need to define the polygons for the paddle in the class. I have 3 types of paddle in my game, so does this mean declaring all the points for all the different paddles as data members? Or is there a better way?
My class so far looks like this:
class Paddle
{
public:
//constructors
Paddle( );
Paddle( PADDLES );
~Paddle( );
//functions
void drawPaddle( );
void movePaddle( GLfloat movement, DIRECTION dir );
//private:
PADDLES type;
DIRECTION direction;
GLfloat move;
Vector3d* currentLoc;
GLint width;
//do I add all the points for all the paddles in here?
};
I am sure a similar problem will preent itself when I implement the blocks as well, so I’d like to clear it up now
The bit at the bottom, couldnt think of a better name. It is used to bounce the ball around the screen so that the blocks may be destroyed. A simple rectangle is the most basic version.
you can use your Vector3d class to represent a vertex and make a polygon class that contained an array or std::vector of vertices. then, your paddle class can have an array or std::vector of polygons. you could store the paddle’s polygon data in a separate file to change it easily w/o recompiling.