REAL Gravity

Non-platform specific questions.

REAL Gravity

Postby willg101 » Thu Aug 25, 2005 1:31 am

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")
http://www.wish-games.com
Old betas now available!!
User avatar
willg101
 
Posts: 473
Joined: Thu Dec 16, 2004 12:08 am
Location: West Michigan
Score: 5 Give a positive score

Postby BeyondtheTech » Thu Aug 25, 2005 1:39 am

One of the things I'm trying to work on right now, considering there are black holes in my game.
User avatar
BeyondtheTech
 
Posts: 270
Joined: Wed Mar 30, 2005 6:34 am
Location: Edison, NJ
Score: 4 Give a positive score

Postby BeyondtheTech » Thu Aug 25, 2005 2:09 am

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.
User avatar
BeyondtheTech
 
Posts: 270
Joined: Wed Mar 30, 2005 6:34 am
Location: Edison, NJ
Score: 4 Give a positive score

Postby makslane » Thu Aug 25, 2005 2:17 am

You can look this sample with vectoradd function:
http://game-editor.com/examples/vectoradd.zip
makslane
Site Admin
 
Posts: 3947
Joined: Sat Apr 05, 2003 6:47 pm
Score: 182 Give a positive score

Postby willg101 » Thu Aug 25, 2005 1:46 pm

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
http://www.wish-games.com
Old betas now available!!
User avatar
willg101
 
Posts: 473
Joined: Thu Dec 16, 2004 12:08 am
Location: West Michigan
Score: 5 Give a positive score

Postby willg101 » Fri Aug 26, 2005 6:52 pm

I've gotten the "earth" to go towards actor1, but it just keps going after it hits actor1...
http://www.wish-games.com
Old betas now available!!
User avatar
willg101
 
Posts: 473
Joined: Thu Dec 16, 2004 12:08 am
Location: West Michigan
Score: 5 Give a positive score

Postby makslane » Fri Aug 26, 2005 7:41 pm

Use a variable to control the script in Draw Actor event
makslane
Site Admin
 
Posts: 3947
Joined: Sat Apr 05, 2003 6:47 pm
Score: 182 Give a positive score

Postby willg101 » Fri Aug 26, 2005 8:01 pm

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);
http://www.wish-games.com
Old betas now available!!
User avatar
willg101
 
Posts: 473
Joined: Thu Dec 16, 2004 12:08 am
Location: West Michigan
Score: 5 Give a positive score

Postby makslane » Fri Aug 26, 2005 9:02 pm

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);
}
makslane
Site Admin
 
Posts: 3947
Joined: Sat Apr 05, 2003 6:47 pm
Score: 182 Give a positive score

Postby willg101 » Fri Aug 26, 2005 9:03 pm

Hmmmm... That didn't help...
http://www.wish-games.com
Old betas now available!!
User avatar
willg101
 
Posts: 473
Joined: Thu Dec 16, 2004 12:08 am
Location: West Michigan
Score: 5 Give a positive score

Postby BeyondtheTech » Tue Sep 06, 2005 8:50 pm

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?
User avatar
BeyondtheTech
 
Posts: 270
Joined: Wed Mar 30, 2005 6:34 am
Location: Edison, NJ
Score: 4 Give a positive score

Postby makslane » Tue Sep 06, 2005 9:32 pm

makslane
Site Admin
 
Posts: 3947
Joined: Sat Apr 05, 2003 6:47 pm
Score: 182 Give a positive score

Postby link is me » Thu Nov 24, 2005 3:50 am

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.
link is me
 
Posts: 3
Joined: Thu Nov 24, 2005 3:28 am
Score: 0 Give a positive score

Postby DilloDude » Wed Mar 01, 2006 10:56 am

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.
Image
User avatar
DilloDude
 
Posts: 866
Joined: Tue Jan 24, 2006 9:51 am
Location: Nyerellion
Score: 58 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest

cron