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.

DarkBASIC Discussion / pong help bouncing 2d help??.. Or what's wrong with this code?

Author
Message
dab
20
Years of Service
User Offline
Joined: 22nd Sep 2004
Location: Your Temp Folder!
Posted: 14th Dec 2004 23:25
I need help with making the little ball in pong to bounce off the screen. I put my code here as well. Remember I want to know how to make it bounce off the edge of the screen. Also how would I make the ball bounce off the paddles? I know I used circles but circles are cool and easy. Please help. Any help would be appreciated.
Ali M Oldboy
20
Years of Service
User Offline
Joined: 6th Nov 2004
Location: England, UK
Posted: 15th Dec 2004 01:37
Well i can help you with bouncing code



and for your second player



Or whatever

In the croud of pain, St. Jimmy stands proud, but we're not insane He says 'We're F***** up' but we're not the same!
Benjamin
22
Years of Service
User Offline
Joined: 24th Nov 2002
Location: France
Posted: 15th Dec 2004 23:38 Edited at: 15th Dec 2004 23:55
What? That just sets collision on you moron Ali.

For the screen:



ballRadius is the size of the ball, I just checked you code and I assume its 8 so use that. Each loop you'll need to put that previous code, then this to update the position:



then you'll need to draw the ball:



Just use that kind of technique and it should be easy. I'll post again explaining how to make it bounce of the paddles in a sec.

CURRENT PROJECT: Chaos Hizzle Demo
Monty87
21
Years of Service
User Offline
Joined: 8th Dec 2003
Location: not very deep in the west country, eng
Posted: 24th Dec 2004 06:00
when the ball gets to the edge of a screen on say the x axis (left or right) polarise (make minus if plus or plus if minus) the xballposition (or equivilent term). my first serise of coding attempts were on 2d ball physics, have'nt progressed any further than that really, but at least i can code balls with my eyes closed now. that sounds dirty.

Monty

Login to post a reply

Server time is: 2025-05-29 10:52:24
Your offset time is: 2025-05-29 10:52:24