HELP!!!! I need to design Pong!!

I’m a first time user of opengl and C++ and I’m trying to design Pong but guess what, don’t know where to start. I haven’t had much luck with getting sample programs that’ll assist me in this design. Can someone recommend any sites,literature that may be useful and helpful to first time users like me, and where I can source good sample programs. NB: I’m not a CS major.

Turns out it’s a common assignment.

Take a look at:
http://www.evl.uic.edu/aej/488/index.html

Look under the link to old assignments.

Good luck.

hey thanks cg-hci_novice, your help is much appreciated

I think your biggest challenge will be the collision detection between the paddle and ball so get the basics done first and save that step till later on.

Before diving in the code, think about how a pong game works. Put 2 blocks and a ball on your mouse carpet if you have to, and visualize how the game plays. Imagine every object having a point (their middle) and a width/height. From that you can easily figure out (if you have some logic :stuck_out_tongue: ) how you would code the collision detection.

Input is easy, read a tutorial on simple win32 input, dont bother with directX or whatever for now. When your up key is pressed, for example, just add to the y value of your paddle object something like that paddle.y+=SPEED_CONSTANT * deltaTime;

You WILL want to obtain the deltaTime (read up google, “deltaTime, getTickCount”) so that you have time-based movement, so that the game will run at the same speed on all computers.

Once you can move your left paddle, for example, just do the same for the other one with 2 other keys.

What really helped me out with making a pong game is drawing the pong game on a 2d geometry paper, then adding in x,y value for each of the object boundaries.

Finally, use ortho mode for your first game. You can draw all objects in screen coordinate instead of world coordinates, it will be much easier to manage.

Hope this helps…

[This message has been edited by dopeflow (edited 09-24-2003).]

If you want a pong source, check out my website www.gdev.org (my domain expires soon so the address wont hold long), in coding section under “Bombtrix”.

Many thanks DopeFlow and cg-hci_novice,
I got the paddles moving the ‘easy way’ i.e. idle callback fct but my guess is that I may want to use the Timer function instead because when I move one paddle the other stops. How do I go about it?
I’m also trying to get the ball moving and that seems to be challenge i.e. collision detection.
Any tips?

Uhhh i just remembered, my bombtrix game is a tetris game LOL :stuck_out_tongue: I also made a pong game just before that one but the source isnt on the site, maybe ill post it. Sorry for the bad info :stuck_out_tongue:

So I noticed, i thought I missed something or I just couldn’t get to the correct links.
Thanks anyway

In the update function you’ll need code like the following (perhaps repeated for diff cases):

// Case 1: Ball going right
if ((horizontal_ball_direction == 1) && (vertical_ball_direction == 0))
if ((x_ball_up_l+ball_width) >= RIGHT_EDGE)
{
horizontal_ball_direction = -horizontal_ball_direction;
x_ball_up_l = x_ball_up_l + (horizontal_ball_velocity*horizontal_ball_direction);
}

I basically used the shell given on that site. Also, didn’t need to support 2 paddles. Sorry.

Hope this helps some.

OHHH I SEEE!!!
Yeah, I’ve got the bouncing based on the direction working.I was having a little problem with the logic behind setting and assigning the ball direction.Man,I won’t forget these days when i finally become a pro…lol

You may also want to check out pong3d.c in the GLFW distribution (based on GLFW, not GLUT, but…). The entire program is 844 lines of C.