Sign in to follow this  
phil67rpg

pong

Recommended Posts

I am working on a very simple pong clone, I am using c++ and openGL,I need to know how to do collision detection, like when the ball hits the paddle, the ball and the paddles are created using the "rectf" function.at the moment the ball passes behind the paddles instead of bouncing off of them, I also need to know how to print a score to the screen, I think it has to do with fonts and bitmaps which I am reading about in "the red book", I also have to get the paddles to move but I think I have that in older code, in advance thank you for all your help

Share this post


Link to post
Share on other sites
Your post seems to contain three different questions:
  1. I need to know how to do collision detection
    What you're looking for is a simple bounding box collision test. Think of how it would work in your head. In order for the two objects to be collided, you'd have to check if the top and bottom collide, the left and right collide, and right and left collide and the bottom and top collide. You should end up with four simple if statements. Once you know that the objects do collide, you'll want to just switch the Y speed by multiplying by -1.
  2. I also need to know how to print a score to the screen
    You'll need to use bitmap fonts and texture them into OpenGL and then render them onto the screen. To my knowledge, there's an example of how to draw text using LMNOpc Bitmap Font Builder somewhere around...
  3. I also have to get the paddles to move but I think I have that in older code
    What are you struggling with there?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this