Jump to content
  • Advertisement
Sign in to follow this  
phil67rpg

pong

This topic is 4367 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Advertisement
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!