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 / What method to code a bouncable projectile?

Author
Message
NanoBrain
19
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Portland, OR
Posted: 5th May 2005 13:38 Edited at: 5th May 2005 14:03
To all,

(DarkBasic Classic)I meant for this post to be within the DarkBasic Classic forum.

Spidyfan made me to think on physics, and so, once again, I have been experimenting at coding a projectiled bouncing ball. The code in the snippet below works fine. However, it was created upon my own simple logic, so I am wondering of a more efficient, and a truly correct to physics method to create this effect.

I have simply used a constant speed, which is one unit per loop, but have made the rate of change in direction to increase after each bounce. Therefore, the change in the angle is what makes the ball to bounce. I am trying to find a method other than using a 'gravity' variable and changing the ball's position on the y axis with it. I am trying to use a vector, I suppose, to create the projectile movement.




+NanoBrain+
Baggers
20
Years of Service
User Offline
Joined: 31st May 2004
Location: Yonder over dem dere hills
Posted: 5th May 2005 18:42
Vectors are definately the way to go.
How i did it first time i tried to write a physics program was to collison check in the direction i was going (sparkys collision dll) and if i hit object i would reflect the motion vector using this command.

What that does if work out the new direction based on the direction of the poly it hits...

Ok this may seem very heavy and just have gone straight over your head if you havnt worked with vectors before but dont worry ! first you need to study vectors and the best tutorial out there is almost certainly Philip's which can be found here...http://www.kentaree-studios.com/tutorials/vectors/index.htm...the rest can be foudn by trawling the web !
Good luck

Login to post a reply

Server time is: 2024-09-23 19:27:07
Your offset time is: 2024-09-23 19:27:07