Java-Gaming.org Hi !
 Featured games (90) games approved by the League of Dukes Games in Showcase (777) Games in Android Showcase (231) games submitted by our members Games in WIP (856) games currently in development
 News: Read the Java Gaming Resources, or peek at the official Java tutorials
Pages: [1]
 ignore  |  Print
 Ball Angles  (Read 3681 times) 0 Members and 1 Guest are viewing this topic.
Daz

Senior Newbie

Java games rock!

 « Posted 2005-02-24 17:00:59 »

Hi, i need to be able to calculate the angels somehow between moving balls on a snooker table in my java 2d game, how do i do this? also how can i send the ball off in the right direction, as a ball has a x and y velocity?
bauerr

Junior Devvie

Java!!!!!!!!!!! !!!

 « Reply #1 - Posted 2005-02-25 16:36:57 »

Hi,

at the moment I have no idea about the first part of your question. The second part is no problem.  You should have the speed of your ball and an  angel. Then it is only math:

The speed is the hypotenuse of  a triangle.

x-direction = Math.cos(angel) * speed;
y-direction = Math.sin(angel) * speed;

Best regards.

Ralf

Daz

Senior Newbie

Java games rock!

 « Reply #2 - Posted 2005-02-25 20:23:33 »

just wanted to make it clear i only get the angle when the 2 balls collide, so i need a formula or do i need to use rotation using point of collision on the balls?

i am very confused!

cheers
Daz

Senior Newbie

Java games rock!

 « Reply #3 - Posted 2005-02-27 12:21:18 »

i know i need to rotate the collided balls at 45 degrees then send them off in that direction, but i need some way of finding out if the 2 balls collided are in a straight line shot, does anyone know about this?
NewbTon

Junior Devvie

Odejava games rock!

 « Reply #4 - Posted 2005-02-27 21:35:55 »

Quote
i know i need to rotate the collided balls at 45 degrees then send them off in that direction, but i need some way of finding out if the 2 balls collided are in a straight line shot, does anyone know about this?

Use Odejava for Gods sake !! Theres no way you gonna figure it out anyway, it will never  work realistically unless you are some sort of math wizard. Odejava can do these things for you and a thousand times better than you and I could ever hope for even if we from now on devoted our lives to it !
darkprophet

Senior Devvie

 « Reply #5 - Posted 2005-02-28 12:25:29 »

maybe he wants to get the mathmatical experience. Theres nothing wrong with that..

But yes, use ODE

DP

Friends don't let friends make MMORPGs.

Blog | Volatile-Engine
Daz

Senior Newbie

Java games rock!

 « Reply #6 - Posted 2005-02-28 12:26:58 »

What is ODE, and how could i import and use it in my Java 2D snooker game?
darkprophet

Senior Devvie

 « Reply #7 - Posted 2005-02-28 12:32:36 »

http://www.ode.org Thats the C++/C library.

http://www.odejava.org And thats the java binding.

Read up on those two, they are physics libraries...

DP

Friends don't let friends make MMORPGs.

Blog | Volatile-Engine
NewbTon

Junior Devvie

Odejava games rock!

 « Reply #8 - Posted 2005-02-28 14:08:23 »

I'm no ODE guru, but with the basic knowlegde I have now I  bet I could make a snooker game in less than a week. At first it looks hard but it's worth the effort,  maybe it will take you 1-2 month to get a grasp on,so what, at your current path  you would still be trying to figure out angles and velocities when ball A hits ball B and it would STILL not look anything near right. With ODE you would get a pro, ultra reality like snooker game.
ODE is for 3D games mostly but it can easely be used from 2D. And hey, while you at it, why don't you go 3D ? The combination of Java3d and ODE would give you a truly pro game.  I used to have the same problems as you until I found ODE. After : to hell with all that, ODE fixes it for me.
I'm not going to spent next 5 years reading up on physics and math.
rdcarvallo

Senior Devvie

Projects: 5
Exp: 15 years

2D Java games forever!

 « Reply #9 - Posted 2005-03-10 00:51:19 »

Daz,

I did all the math to calculate the new directions and speeds for Balls of any radius/mass, But the other day I found a easier algorithm for it.

Look it here: http://freespace.virgin.net/hugo.elias/models/m_snokr.htm

Hope it helps you!

Rafael.-

Pages: [1]
 ignore  |  Print

 hadezbladez (289 views) 2018-11-16 13:46:03 hadezbladez (157 views) 2018-11-16 13:41:33 hadezbladez (289 views) 2018-11-16 13:35:35 hadezbladez (71 views) 2018-11-16 13:32:03 EgonOlsen (2142 views) 2018-06-10 19:43:48 EgonOlsen (2152 views) 2018-06-10 19:43:44 EgonOlsen (1364 views) 2018-06-10 19:43:20 DesertCoockie (1975 views) 2018-05-13 18:23:11 nelsongames (1600 views) 2018-04-24 18:15:36 nelsongames (2248 views) 2018-04-24 18:14:32
 Deployment and Packagingby mudlee2018-08-22 18:09:50Java Gaming Resourcesby gouessej2018-08-22 08:19:41Deployment and Packagingby gouessej2018-08-22 08:04:08Deployment and Packagingby gouessej2018-08-22 08:03:45Deployment and Packagingby philfrei2018-08-20 02:33:38Deployment and Packagingby philfrei2018-08-20 02:29:55Deployment and Packagingby philfrei2018-08-19 23:56:20Deployment and Packagingby philfrei2018-08-19 23:54:46
 java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org