Java-Gaming.org
 Featured games (81) games approved by the League of Dukes Games in Showcase (497) Games in Android Showcase (114) games submitted by our members Games in WIP (563) games currently in development
 News: Read the Java Gaming Resources, or peek at the official Java tutorials
 Home Help Search Login Register
Pages: [1]
 ignore  |  Print
 Ball Angles  (Read 2000 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 Member

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
 Games published by our own members! Check 'em out!
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 Member

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 Member

Go Go Gadget Arms

 « 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 Member

Go Go Gadget Arms

 « 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 Member

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 Member

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

You cannot reply to this message, because it is very, very old.

 Add your game by posting it in the WIP section, or publish it in Showcase. The first screenshot will be displayed as a thumbnail.
 BurntPizza (15 views) 2014-09-19 03:14:18 Dwinin (33 views) 2014-09-12 09:08:26 Norakomi (59 views) 2014-09-10 13:57:51 TehJavaDev (82 views) 2014-09-10 06:39:09 Tekkerue (40 views) 2014-09-09 02:24:56 mitcheeb (63 views) 2014-09-08 06:06:29 BurntPizza (46 views) 2014-09-07 01:13:42 Longarmx (33 views) 2014-09-07 01:12:14 Longarmx (39 views) 2014-09-07 01:11:22 Longarmx (36 views) 2014-09-07 01:10:19
 BurntPizza 38x Riven 18x Rayvolution 17x princec 17x basil_ 16x ags1 16x KevinWorkman 15x kevglass 12x LiquidNitrogen 11x nsigma 11x theagentd 11x HeroesGraveDev 9x SHC 7x The Lion King 7x Gibbo3771 6x cylab 6x
 List of Learning Resources2014-08-16 10:40:00List of Learning Resources2014-08-05 19:33:27Resources for WIP games2014-08-01 16:20:17Resources for WIP games2014-08-01 16:19:50List of Learning Resources2014-07-31 16:29:50List of Learning Resources2014-07-31 16:26:06List of Learning Resources2014-07-31 11:54:12HotSpot Optionsby dleskov2014-07-08 01:59:08
 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