Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / Simple Gravity Code

Author
Message
Evilcatt09
20
Years of Service
User Offline
Joined: 2nd Oct 2003
Location:
Posted: 24th Apr 2004 06:20
Can anyone show me a simple couple of lines of code that I can use as gravity for a 2D lunar lander type of game.

I found one tutorial a while ago that had a great lunar lander tutorial, if anyone knows what site this is on I would appreciate it if you could tell me.

Thanks

You want me to get a life? Ok, hold on a sec. *picks up the controller and presses Up,Down,Right,A,Left,B,Y* There you go now I have 50!
apophis
21
Years of Service
User Offline
Joined: 14th Jul 2003
Location:
Posted: 24th Apr 2004 06:40
You could do something like:

ground = get ground height()
landery = object position y(1)
gravity = landery - gound
if landery > ground then move object down 1,gravity

note: I am using 1 for the object number of your lander
Also the move object down command may not always work because it corresponds to the objects forward facing direction.
Hope this helps

-Apophis
CattleRustler
Retired Moderator
21
Years of Service
User Offline
Joined: 8th Aug 2003
Location: case modding at overclock.net
Posted: 24th Apr 2004 15:33 Edited at: 24th Apr 2004 15:33
in your main loop you can try to move you main object downward by decrementing its Y position a wee bit each pass, but you can use collision on the ground/platform items to stop the object from moving thru them. Gives the appearance of gravity.


Home of the VB.NET Class Builder Utility - Demo and FULL versions now available!!

Login to post a reply

Server time is: 2024-09-22 06:43:42
Your offset time is: 2024-09-22 06:43:42