Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length

 
Advanced search

1075922 Posts in 44152 Topics- by 36120 Members - Latest Member: Royalhandstudios

December 29, 2014, 03:45:50 PM
TIGSource ForumsDeveloperTechnical (Moderators: Glaiel-Gamer, ThemsAllTook)Realistic gravity vector in a 2d space
Pages: [1]
Print
Author Topic: Realistic gravity vector in a 2d space  (Read 756 times)
theman515
Level 0
**


The code... the code!!


View Profile WWW Email
« on: October 01, 2011, 11:57:31 PM »

hey guys,

does anyone know the magnitude of a realistic gravity vector for a game with a 800x600 window and a 1.8 meter tall main character that is 38 pixels tall.

thanks in advance  Gentleman
Logged
dustin
Level 6
*


View Profile Email
« Reply #1 on: October 02, 2011, 12:36:10 AM »

In a very general sense...


38 pixels/1.8 meters = 21 pixels/meter

21 pixels/meter * 9.8 meters/seconds^2 (gravity) = 205.8 pixels/seconds^2

somehow I feel like that's not what your asking but I can't think of what else you might mean.

Logged
MattG
Level 5
*****

Pictures Of Trains


View Profile Email
« Reply #2 on: October 02, 2011, 06:09:26 AM »

use meters as units not pixels. Dont fix your physics to a window size or doing anything but that size will break your game.
Logged
theman515
Level 0
**


The code... the code!!


View Profile WWW Email
« Reply #3 on: October 02, 2011, 11:40:54 AM »

ok, how to convert pixel movement to meters then?

as for my original question, i slept on it and did this math:

9.8 m/s^2 * 38 pixels/1.8 meters * 1 sec/100 ms * 1 sec/100 ms (since it's seconds squared and the delta T returned from my engine is milliseconds)

and i got something like .02 p/ms^2 which works fine but will it break if the window size changes?
Logged
Zaphos
Guest
« Reply #4 on: October 02, 2011, 01:06:56 PM »

The window size in itself isn't relevant, but if the height in pixels of the character scales with the window size then you would expect to similarly scale the gravity vector (same as you'd rescale any movement vector).  In games with pixel art and no zooming/whatever (or where the zoom is handled transparently, so your movement code still 'sees' the original res, etc), this may not really be a concern.  It's a common sense sort of issue anyway; I'm sure you can figure out if you need to rescale and how much.
Logged
theman515
Level 0
**


The code... the code!!


View Profile WWW Email
« Reply #5 on: October 02, 2011, 01:16:00 PM »

alright, thanks guys. i think i got it.
Logged
Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic