Polygons in classes

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 );

	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

What exactly is a paddle?

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:

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.


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.

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?

Is that the only way to do it coredump? The vertices have to be contained as Paddle data members then?

well, it’s certainly not the only way to do it. you can store your data however you wish.