Page 1 of 1

REAL Gravity

PostPosted: Thu Aug 25, 2005 1:31 am
by willg101
How do I make this happen, like what code would I use?
Image
(red is the original force, green is gravity, blue is the path that the earth "follows")

PostPosted: Thu Aug 25, 2005 1:39 am
by BeyondtheTech
One of the things I'm trying to work on right now, considering there are black holes in my game.

PostPosted: Thu Aug 25, 2005 2:09 am
by BeyondtheTech
http://www5f.biglobe.ne.jp/~mcs/blackhole.html

Here's a freeware program, but it looks darn complicated.

You might want to stick to simpler thinking - I'm using the idea that the closer you are to the object, the closer you'll be pulled into it.

Theory:
Save the current angle of the object
Get straight trajectory angle
Determine pull by distance
Move object by that amount of pull
Restore current angle of object.

In theory, the resulting angle would have changed and bent towards the black hole.

PostPosted: Thu Aug 25, 2005 2:17 am
by makslane
You can look this sample with vectoradd function:
http://game-editor.com/examples/vectoradd.zip

PostPosted: Thu Aug 25, 2005 1:46 pm
by willg101
THANK YOU SOO MUCH! This is what my game is based on, this should make is soo much easier!

Now, one question: If my ship is going up, will it be pulled to the mouse while going up?

Not that it matters, but here is what I want my game to be like(same idea): http://www.bigideafun.com/penguins/arcade/doom_funnel/default.htm

PostPosted: Fri Aug 26, 2005 6:52 pm
by willg101
I've gotten the "earth" to go towards actor1, but it just keps going after it hits actor1...

PostPosted: Fri Aug 26, 2005 7:41 pm
by makslane
Use a variable to control the script in Draw Actor event

PostPosted: Fri Aug 26, 2005 8:01 pm
by willg101
How? What code would I use?

I am currently using this code:
Code: Select all
double mouseangle = direction(xscreen, yscreen, object.x, object.y);
vectoradd(&angle, &directional_velocity, mouseangle, 1);
directional_velocity = min(directional_velocity, 10);

PostPosted: Fri Aug 26, 2005 9:02 pm
by makslane
Create a variable "earthHit".
In your Collision Event add the script:
earthHit = 1;

In Draw Actor event:

Code: Select all
if(!earthHit)
{
    double mouseangle = direction(xscreen, yscreen, object.x, object.y);
    vectoradd(&angle, &directional_velocity, mouseangle, 1);
    directional_velocity = min(directional_velocity, 10);
}

PostPosted: Fri Aug 26, 2005 9:03 pm
by willg101
Hmmmm... That didn't help...

PostPosted: Tue Sep 06, 2005 8:50 pm
by BeyondtheTech
Any update to this scenario? I've got a black hole that's acting like some other hole I don't want to mention, but I'll probably blame that on my code.

I'll give willg101's coding a shot, but what was your issue?

PostPosted: Tue Sep 06, 2005 9:32 pm
by makslane

PostPosted: Thu Nov 24, 2005 3:50 am
by link is me
its easy in your script just put different gravity points and plot them on the x and y axis points of your choice it took me a couple days to figure this out if you get it right it should look kind of like a tornado.

PostPosted: Wed Mar 01, 2006 10:56 am
by DilloDude
I thought of an idea, but I'd need to have a good gravity system working. Probably write a gravity function with properties like range and strength. I would want at least two types of actors with 'gravitational' force: one pulling an object toward itself and another pushing it away (these could probably be controlled by 'strength'). The idea is to use them to simulate hills and valleys on a golf-course. Hills would cause the ball to roll away from them, and valleys would pull it toward them. But I'd need a solution that works well, and the ball's velocity would have to be relative to the distance.