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?
Welcome to the forum.
You may wish to tell the details of your problem.
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?
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
thanks you made me think along a path that couldn't come to me haha, sorry i took so long to respond