View Full Version : Polygons in classes

04-11-2002, 02:54 AM
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
Paddle( );
Paddle( PADDLES );
~Paddle( );

void drawPaddle( );
void movePaddle( GLfloat movement, DIRECTION dir );

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 http://www.opengl.org/discussion_boards/ubb/smile.gif

Michael Steinberg
04-11-2002, 05:21 AM
What exactly is a paddle?

04-11-2002, 05:53 AM
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.

Check here if you're not familiar with the game:

04-12-2002, 04:39 AM
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.


04-12-2002, 04:52 AM
It is a thing you hit things with.
When you where a child you may have had you mom hit your bottom with a paddle. http://www.opengl.org/discussion_boards/ubb/smile.gif

But in this case the paddle is the thing at the bottom of the screen that the ball hits and is moved by the user.

-------- Blocks to be hit by ball.

* ball

__ paddle

Originally posted by Michael Steinberg:
What exactly is a paddle?

04-12-2002, 06:07 AM
Is that the only way to do it coredump? The vertices have to be contained as Paddle data members then?

04-12-2002, 05:37 PM
well, it's certainly not the only way to do it. you can store your data however you wish.