1. ## gravity effecting velocity

I got a problem with gravity effecting velocity.
my gravity works like this:

you.vl.y-=grav*speed; // the speed is for frame limting.
you.pos.y+=you.vl.y*speed*3;

Now lets say i wan't to change the y velocity so it will throw me up to 100. I can do this but what i want is to change the gravity and still have the velocity get me to 100.
So how would i do this? I can't figer it out.

2. I really have no idea what you're asking. But remember that the value of gravity is not a velocity but an accelleration.

grav = -9.8 ///it's a constant. that's the ACTUAL gravitational constant regarding earth, but it would change for your program.

velocity = -9.8t + initlvel //t is the amount time the object has been affected by gravity, initvel is the initial velocity the object has when it "jumps"

ypos = .5(-9.8)t^2 + initvel(t) + initypos

hope that helps! =) a little calc goes a long way...

edit: errors

3. all i need is a that tells you how many meters sec you need to be moving to get 300 meters off the ground no matter what the gravaity is.

4. all i need is a that tells you how many meters sec you need to be moving to get 300 meters off the ground no matter what the gravaity is.
Well, getting to 300 meters is going to be dependent on the variables (gravity, velocity, etc...). Try looking at SmashBro's post again, because it is explained fairly well in it.

5. Okay I think I know what you want now.

Just make gravity a negative number. We'll call it grav.

If you shoot something straight up into the air and it gets to 300 meters exactly, then at 300 meters, the velocity is 0.

So if we take the scenario that if you drop a ball from a 300 meter tall building, if you find the velocity of the ball when it hits the ground, that's the same velocity you need to shoot it up into the air with, since grav will always be constant.

finalypos = .5grav(t^2) + initvel(t) + initypos

The final ypos is 0, when the ball hits the ground. grav is whatever negative constant you want it to be (as you requested.) t is the time it takes for the ball to hit the ground; it's what we're solving for.

initvel is 0--because at the moment you let go of the ball from the top of the building, it has no velocity. initypos is 300 meters.

So then we have

0 = .5grav(t^2) + 0 + 300
-600 = grav(t^2)

-600/grav = t^2

t = sqrt(-600/grav)

That looks complicated but if you had a constant for gravity, it would just be one number at this point. Anyway, that's the time that the ball would have a positive velocity after you throw it up. We can plug this nuber into my previous velocity formula:

velocity = grav(t) + initvel //initvel is 0

velocity = grav(sqrt(-600/grav))

So, there's your answer. Or, for any verticle distance the formula would be...

velocity = grav(sqrt(-2desiredheight/grav))

Of course, if you don't understand exactly how all of that works, the formula isn't going to help you as far as creating video games goes. And if you didn't understand any of that at all, then I suggest taking calculus and physics before getting into that kind of programming, because it definitely helps. =P