Java-Gaming.org Hi !
 Featured games (91) games approved by the League of Dukes Games in Showcase (757) Games in Android Showcase (229) games submitted by our members Games in WIP (843) games currently in development
 News: Read the Java Gaming Resources, or peek at the official Java tutorials
Pages: [1]
 ignore  |  Print
 Ball Angles  (Read 3524 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

 EgonOlsen (37 views) 2018-06-11 01:43:48 EgonOlsen (20 views) 2018-06-11 01:43:44 EgonOlsen (39 views) 2018-06-11 01:43:20 DesertCoockie (186 views) 2018-05-14 00:23:11 nelsongames (122 views) 2018-04-25 00:15:36 nelsongames (121 views) 2018-04-25 00:14:32 ivj94 (861 views) 2018-03-24 20:47:39 ivj94 (122 views) 2018-03-24 20:46:31 ivj94 (758 views) 2018-03-24 20:43:53 Solater (139 views) 2018-03-17 11:04:08
 Java Gaming Resourcesby philfrei2017-12-05 19:38:37Java Gaming Resourcesby philfrei2017-12-05 19:37:39Java Gaming Resourcesby philfrei2017-12-05 19:36:10Java Gaming Resourcesby philfrei2017-12-05 19:33:10List of Learning Resourcesby elect2017-03-13 14:05:44List of Learning Resourcesby elect2017-03-13 14:04:45SF/X Librariesby philfrei2017-03-02 08:45:19SF/X Librariesby philfrei2017-03-02 08:44:05
 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