Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / Simple pong collision problem

Author
Message
Tattered brush
15
Years of Service
User Offline
Joined: 1st Dec 2008
Location:
Posted: 26th Mar 2009 14:23
Hi guys

I've been following through a tutorial in a book to create a basic pong clone.

I've followed the code exactly, however the collision detection when the ball hits the paddle is not working, can anyone help please?

LBFN
17
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 26th Mar 2009 20:35
Replace this code:


with this code:



It's not a good idea to use the point command in games, as it is too slow.

Good luck on your game.

Tattered brush
15
Years of Service
User Offline
Joined: 1st Dec 2008
Location:
Posted: 26th Mar 2009 22:48
Thanks for your help and advice. There is a superb community out there behind DBPro, I wouldn't get very far without it.
LBFN
17
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 26th Mar 2009 23:06
You're welcome.

You might consider some options in your coding:
1. using sprites instead of pasting images
2. using the backdrop instead of cls each loop
3. drawing the images separately and then loading them into the program

Tobo
19
Years of Service
User Offline
Joined: 12th May 2005
Location:
Posted: 30th Mar 2009 15:29
LBFN,

Quote: "2. using the backdrop instead of cls each loop"


Can you explain the above in a little more detail please (how and why etc).

Many thanks.

T
LBFN
17
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 30th Mar 2009 18:26
Tobo:

I ran this code at a sync rate of 0 using both methods and achieved essentially the same results (around 679 - 692 FPS).

With 2D programs I have seen a very marginal speed increase in game speed (if you use the backdrop) if you have a ton of images to display. Either method will work fine, as long as you don't use 3D objects. You will need the backdrop if you are using 3D objects. So, if all you are ever going to write are 2D programs, it really doesn't matter.

Just for fun I changed the code to use a sphere as a ball and 3D boxes as paddles and it ran at 800+ FPS using the backdrop, a 100+ FPS increase.

LB

Login to post a reply

Server time is: 2024-09-28 04:18:15
Your offset time is: 2024-09-28 04:18:15