http://GameProgrammer.Com

Programming

GP Mailing List
     Thread Index
     Date Index

ATXGPSIG List
     Thread Index
     Date Index

Google
>

Home

Wise2Food



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Bouncing balls. WAS Re: GP: Flipping a point across a line: The answer



well... if you want realistic bouncing - and you *do* want realistic
bouncing, otherwise you're going to piss off the players - then i'm afraid
you're going to have to use some, if not all, of those functions you said
you didn't want to use... in some form or another.
you can probably get away with not using sqrt, but that's about it...
of course, the trick in these circumstances (doesn't really apply any more,
due to the speed of modern fpus) is to use tables of approximate values, so
(for example) you don't have to calculate the arc tan of an angle each time
you need it - you can just look up the closest answer in your table. this
gives you a nice trade off between accuracy and speed (especially for those
with older machines).
of course, you still have to calculate the values in the first place, but
that'll only be once, at the beginning of the program.

so, to sum up, you can pretty much forget about finding a method to do it
realistically without using complex mathematical functions - as proof of
this, consider the following: if it were possible to simulate these sort of
mechanics with simple maths, then that's all we'd be taught at school, cos
there'd be no need for the tricky stuff.

hope that helps a little,
andy.

--

Andy Burgess, Software Engineer.
Information Systems Production Software - 'PA' Listings.
eMail: andrewjb@padd.press.net
Phone: (01430) 488 224

----- Original Message -----
From: Eudoxus3 <Eudoxus@freeuk.com>
To: Game programmer <gameprogrammer@gameprogrammer.com>
Sent: Wednesday, September 08, 1999 12:59 PM
Subject: Re: Bouncing balls. WAS Re: GP: Flipping a point across a line: The
answer


> On Wed 08 Sep, Kevin Shea wrote:
> > Can I ask what sort of thing you're actually doing and for what reason
> > are you doing it?
> A game/graphics engine because I want to.  In a small group.
>
> > Some more information would be useful to give everyone a chance to help
> Ok...
>
> Right now, all I want to do is have a Java applet which shows two or
> more balls, of indeterminate size (guarenteed >0), mostly moving, but
> sometimes not, and have them bounce off each other.  No weight, mass or
> density or anything has to be known - just a guarentee that the the place
> they're at after the collision is relative to the angle they hit at when
> travelling towards each other.
>
> Btw: Could I ask Don to re-post his answer to this problem?
>
> At the moment all I know is...
>
> ballA.x_location ballA.y_location
> ballB.x_location ballB.y_location
>
> ballA.x_direction ballA.y_direction
> ballB.x_direction ballB.y_direction
>
> The method I'm using to define the direction and speed of the balls is
> a signed integer for the X and Y directions.  Eg: if a ball is travelling
> at XD = +10 and YD = -10 it is going right at a horizontal speed of 10
> units per frame and down at a vertical speed of 10 units per frame.
>
> (Incidentally the units are pixels, but they don't necessarily have to
be.)
>
> I plan to convert the final 2D code into 3D, so that we can use our engine
> to create (eg:) a Quake-style game (that's a regular expression nowadays!)
> involving `footballs` (probably made of steel! :).  The balls could be
> kicked and maybe even shot at and bounce off walls etc. and EACH OTHER!!!
>
> So, yes, this is a game question, although it involves geometry, because
> games require good geometry (which I don't really have).  My technique is
> to get something which works, refine it and speed it up then turn it to
> some form of 2D or 3D version which we can use.  Speed is the issue for
us.
>
> If u take a look at the 3D elstic sheet on my web page graphics section
> you'll be able to have a go on an example - it evolved from a 2D program.
>
> Sorry this was a bit long...
>
>
> Regards,
>
> Matt. W.
> --
>       ***   eudoxus@freeuk.com   ***
> ***   http://www.eudoxus.freeuk.com/   ***
> mwebster@apsoft.co.uk   http://members.xoom.com/eudoxusM/
>
> =================================================================
> To SUBSCRIBE or UNSUBSCRIBE please visit
> http://gameprogrammer.com/mailinglist.html

=================================================================
To SUBSCRIBE or UNSUBSCRIBE please visit
http://gameprogrammer.com/mailinglist.html