Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Help needed regarding a billiards game
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
A.J




PostPosted: Mon Apr 07, 2008 7:44 pm   Post subject: Help needed regarding a billiards game

All I have right now are the balls moving around at random positions and velocities and hitting each other or sinking if they reach the corner/side pockets.
I need to add friction to the balls so that they don't move forever........
I need help regarding what I should do to the horizontal/vertical velocity each time I update the balls information.....
and if anyone could help me make the balls 3-D (or make a tutorial on making 3d engines/graphice) I'll really appreciate it Very Happy

thanks,
A.J



Billiards.zip
 Description:
here it is!!!

Download
 Filename:  Billiards.zip
 Filesize:  337.95 KB
 Downloaded:  74 Time(s)

Sponsor
Sponsor
Sponsor
sponsor
Saad




PostPosted: Mon Apr 07, 2008 9:13 pm   Post subject: Re: Help needed regarding a billiards game

All you need is newtons second law, F = ma, now the only force on the ball is the force of friction.

Therefore u Fn = ma (Where u is the coefficient of friction)
Since its a flat table, Fn is the same as its weight
umg = ma (g being the gravity)
ug = a

Therefore the magnitude of the acceleration of the friction force is u * g, now take a normal vector of your current velocity and multiply that by -1 since friction is in the opposite direction and multiply that by the magnitude of the acceleration of friction

Some pseudo code

code:
var V := CurrentVelocityVector
var accelerationMagnitude := u * g %% (Where u is the coefficient of friction and g is the gravity on earth)
var normalVelocityVector := (V / magnitude (V))
var accelerationVector := (normalVecloityVector * -1) * accelerationMagnitude
CurrentVelocityVector := CurrentVelocityVector + accelerationVector * timeStep


Play around with the u value to get it to apply the right amount of friction

As for 3D, look up 3d projection onto a 2D screen
A.J




PostPosted: Mon Apr 07, 2008 9:45 pm   Post subject: Re: Help needed regarding a billiards game

thx saad, I owe u Wink
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 3 Posts ]
Jump to:   


Style:  
Search: