PDA

View Full Version : My TGF Physics Engine


Rob223
04-21-2007, 01:27 PM
I've attempted to create a ball gravity engine in TGF. It's a simple one, and It took me about half an hour, so don't expect any miracles. In fact, I would go on to say that it's terrible compared to modern physics, but hey, it's a start for me, i've never tried making a physics engine b
Here's some basic info about how the engine works.

The ball increases it's speed if it's facing downwards.
It decreases it's speed if it's facing upwards.
If it is facing upwards and to the right, it adds 1 to the direction value until it is facing (therefore going) downwards
If it is facing upwards to the left, it minuses 1 from the direction value until it is facing downwards.
It "bounces" off the walls and floor by taking or adding a different amount to it's direction value depending on which direction it is facing.
If the ball is facing directly upwards, it will randomly go slightly left or right to start off the gravity.
If the mouse is held, the ball will ignore all of these and head towards the pointer until the pointer is released.
I don't have friction yet, which produces some strange effects when you skim the ball along the ground (it speeds up >_<)

As I've said, it's simple, its not very realistic, but I'm hoping to improve it greatly in the future and possibly use it in one of my games.

Download Link (http://www.mooload.com/new/file.php?file=files/210407/1177161982/ballgravity.zip)

(scroll down to get to the download)

Can anyone help me with this? Does anyone want to help with this? Why is my cheese-bread not finished?

Wrestler#1
04-21-2007, 07:22 PM
Well, maybe you could get some help from wikipedia, because it is not very reallistic YET.
Hey, it is really good for the begining, so keep it up :D

Rob223
04-21-2007, 07:32 PM
Thanks! I'm having problems adding friction because once the ball reaches speed 0 it won't follow the mouse, and gravity decreases for some reason... damn these little annoyances.

fusion1224
04-22-2007, 12:18 AM
The download link doesn't work for me unfortunately. I'd like to help you though. What is TGF?

Rob223
04-22-2007, 12:41 AM
Clickteam product. Here's a mirror for the download.

Mirror (http://www.hotlinkfiles.com/files/1367_zuqlg/ballgravity.zip)

fusion1224
04-22-2007, 01:14 AM
Cool demo. With physics simulations the way a particle is represented is by it's position, velocity and acceleration vectors. It isn't usually represented by its direction or speed, even though that seems the most logical way of doing things.

When I started out programming the physics in my game that I'm making, I had the player represented by speed and direction. I found that this made everything more complicated then it actually should have been. For example it was very hard to implement gravity because you had to calculate the trajectory that the particle took and represent it in the form of speed and direction.

If you represent a physically simulated particle by it's position, velocity and acceleration - all you have to do is apply forces to it. Gravity acts on the particle as a downward force.

This may seem more complicated than speed and direction at first, but you'll see that its a more logical way of doing a physics simulation and it allows you to do so much more. There are heaps of articles on the Internet about this, here are some:

http://www.teknikus.dk/tj/gdc2001.htm
http://www.gaffer.org/game-physics/

Rob223
04-23-2007, 03:34 PM
I've seen things done like that before. It IS a much more logical way of doing things, but I just can't get collision detection to work with it in TGF. >_< I must try it in MMF2 at some point (sequel to tgf)