1. Member
Join Date
Apr 2010
Posts
10
Rep Power
0

## ground?

This may have been asked, but I wasn't sure what to search for exactly. I want to make "ground" for a game, how would you go about doing that? I also wanted gravity, and there will be holes and stuff, so the character should stand on the ground, and also will be able to jump and stuff. How would I go about doing this?

2. Member
Join Date
Apr 2010
Posts
10
Rep Power
0
Well it kinda is the problem, it's a very generic question I have no idea where to start. I did figure out the ground thing, was very simple once I actually did it, but I still have no idea where to begin making gravity. Would it be easier to make each sprite "fall" when nothing is underneath it or just have something more like real gravity?

3. Senior Member
Join Date
Mar 2010
Posts
266
Rep Power
8
Think Physics.

if your character stands on the ground (its Y coordinate is same as Y coordinate of the ground), there's nothing to do.

if however your character is above the ground, gravity kicks in. from physics:

v = at
y = vt

a = acceleration
v = velocity
y = y-coordinate
t = time

acceleration is constant. On real Earth, it equals 9.8, for your game, pick a value that looks good.

Have a thread that kicks in every 50 milliseconds, for example, and does this:

// timeElapsed = 50 milliseconds
velocityNew = velocityOld + GRAVITY_CONSTANT * timeElapsed;
yCoordinateNew = yCoordinateOld + velocityNew * timeElapsed;

and you're done! just make sure to stop this thread as soon as the character hits the ground

4. Member
Join Date
Apr 2010
Posts
10
Rep Power
0
thanks you made me think along a path that couldn't come to me haha, sorry i took so long to respond

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•