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.

Dark GDK / Angles for Pong

Author
Message
Cooldude
17
Years of Service
User Offline
Joined: 10th Nov 2007
Location:
Posted: 26th Nov 2007 14:24
Yo,
I'm making a pong game and I have got far enough to make the paddles move. I need a way to make my ball follow an imaginary line or something like that and follow it then bounce and in quick time draw another lin for it to follow. I need to use angles though. Anyone know how???
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 26th Nov 2007 14:32
I'm not sure that using angles is the best way to do it - use a vector instead. That way, when you bounce off a horizontal surface all you need to do is reverse the y component of the vector, and if bouncing off a vertical surface, reverse the x component.

Also, if you don't mind doing the conversion, there was some code I posted in my plug-ins thread in the DLL forum for bouncing a circle off a box that handled it in exactly this way - here it is:


It should be trivial to convert it.

Utility plugins collection and
http://www.matrix1.demon.co.uk for older plug-ins and example code
Zotoaster
19
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 26th Nov 2007 20:12
I do it like:

If Collision then BallAngle = SurfaceAngle - BallAngle

"It's like floating a boat on a liquid that I don't know, but I'm quite happy to drink it if I'm thirsty enough" - Me being a good programmer but sucking at computers

Login to post a reply

Server time is: 2024-11-19 17:23:48
Your offset time is: 2024-11-19 17:23:48