Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (477)
Games in Android Showcase (106)
games submitted by our members
Games in WIP (533)
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 1924 times)
0 Members and 1 Guest are viewing this topic.
Offline Daz

Senior Newbie




Java games rock!


« Posted 2005-02-24 18: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?
Offline bauerr

Junior Member




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


« Reply #1 - Posted 2005-02-25 17: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

Offline Daz

Senior Newbie




Java games rock!


« Reply #2 - Posted 2005-02-25 21: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!
Legends of Yore - The Casual Retro Roguelike
Offline Daz

Senior Newbie




Java games rock!


« Reply #3 - Posted 2005-02-27 13: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?
Offline NewbTon

Junior Member




Odejava games rock!


« Reply #4 - Posted 2005-02-27 22: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 !
Offline darkprophet

Senior Member




Go Go Gadget Arms


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

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

But yes, use ODE  Grin

DP

Friends don't let friends make MMORPGs.

Blog | Volatile-Engine
Offline Daz

Senior Newbie




Java games rock!


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

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

Senior Member




Go Go Gadget Arms


« Reply #7 - Posted 2005-02-28 13: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
Offline NewbTon

Junior Member




Odejava games rock!


« Reply #8 - Posted 2005-02-28 15: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.
Offline rdcarvallo

Senior Member


Projects: 5
Exp: 15 years


2D Java games forever!


« Reply #9 - Posted 2005-03-10 01: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.

pw (24 views)
2014-07-24 01:59:36

Riven (24 views)
2014-07-23 21:16:32

Riven (18 views)
2014-07-23 21:07:15

Riven (21 views)
2014-07-23 20:56:16

ctomni231 (50 views)
2014-07-18 06:55:21

Zero Volt (45 views)
2014-07-17 23:47:54

danieldean (36 views)
2014-07-17 23:41:23

MustardPeter (39 views)
2014-07-16 23:30:00

Cero (54 views)
2014-07-16 00:42:17

Riven (55 views)
2014-07-14 18:02:53
HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54

HotSpot Options
by Roquen
2014-05-06 15:03:10

Escape Analysis
by Roquen
2014-04-29 22:16:43

Experimental Toys
by Roquen
2014-04-28 13:24:22
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
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!