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 / challenge to all math wizards

Author
Message
MASTER OF PUPPETS
20
Years of Service
User Offline
Joined: 9th Jun 2004
Location: Trapped Under Ice
Posted: 10th Jun 2004 00:59
i am making an airhockey simulation game and want to be able to do a couple of things:

1) i want to hit the puck at angles that are decided by the direction of the paddle

2) i want the puck to hit the sides and bounce off at the correct angle that it would in real life

i have been trying to come up with an equation that will be correct at every angle no matter what but i am not very good at that yet so...please post some code that could possibly help.
P.S. PLEEEEEEAAAAAASE!!!
AND THANX IN ADVANCE

metal is not music but a way of life...all hail to the reigning king METALLICA!!!
indi
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 10th Jun 2004 05:08
simple pong snippets will have the code for you to acheive this


fall down seven times, stand up eight
Night Giant
21
Years of Service
User Offline
Joined: 26th Jul 2003
Location:
Posted: 10th Jun 2004 06:57
well, i don't think you can have one equation for every angle, i think you will have to have piecewise functions, because sin only returns angles from -90 to 90 and cosine from 0 to 180. it's really just simple trig.

oh, wow. insignificantpunks.cjb.net.
no: website for progs yet.
Phaelax
DBPro Master
22
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 10th Jun 2004 09:47
I'd go the way of vectors myself.

"eureka" - Archimedes
Night Giant
21
Years of Service
User Offline
Joined: 26th Jul 2003
Location:
Posted: 11th Jun 2004 00:41
well, that'd be the easy way out, lol.

oh, wow. insignificantpunks.cjb.net.
no: website for progs yet.
eBusiness
21
Years of Service
User Offline
Joined: 26th May 2004
Location:
Posted: 11th Jun 2004 03:06
Out angle equal to 180+2*(banner angel)-(in angel)

Afterwards add 2*(banner movement in banner normal direction) to the pucks movement, for speed in/decrease when the paddle is moving (when I refer to banners I mean both banners and paddles)

Blitz Basic coder, please flame me.
Xander
22
Years of Service
User Offline
Joined: 3rd Mar 2003
Location: In college...yeah!
Posted: 11th Jun 2004 08:14
I must be strange...

When I created my first pong game I used variables for movex and movey, not an angle and velocity. That way, you can very very easily add bouncing in:

If it hits a wall on the top or bottom of the screen:
ballmovey=ballmovey*-1

If it hits a paddle:
ballmovex=ballmovex*-1
ballmovey=ballmovey+(paddlemovey/2)

Of course, if you have a vector, you can use tan(angle) to get the slope of the vector, giving you an x and y movement...

I found this way to be the easiest, anyone else use this method?

Xander Moser of Bolt Software
Firewall: Your Computer's First Defense - Real Time Strategy game
[href][/href]
bibz1st
22
Years of Service
User Offline
Joined: 2nd Jan 2003
Location:
Posted: 11th Jun 2004 20:19
This used to work for me, see if you can make any sense of it.
rob
Underworld 1020
21
Years of Service
User Offline
Joined: 2nd Mar 2004
Location: NY, USA
Posted: 13th Jun 2004 04:48
"metal is not music but a way of life...all hail to the reigning king METALLICA!!!"

My favorite band and the reason I play electric guitar!
bibz1st
22
Years of Service
User Offline
Joined: 2nd Jan 2003
Location:
Posted: 18th Jun 2004 20:08
which means what exactly?

Login to post a reply

Server time is: 2025-05-27 18:57:38
Your offset time is: 2025-05-27 18:57:38