Qbasicnews.com

Full Version: Its Been a While
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Its been a really long time scince ive done someting major in QB. so ive decided to work on a Gravity engine for games... that was my first mistake. I realized that Ive only scratched the surface of how to simulate gravity, and now, I need help. any algorythms or formulas would be helpful, thanx :wink:

Mech
Well, I just have x, y, vx and vy. In each loop, vx gets added to x, and vy gets added to y. If no obstacles, vy increases linearly, simulating gravity: vy = vy + gravity. vy gets a negative boost when player jumps (vy = -jumpStrength), and vx is controled by LEFT and RIGHT keys. This is in my platformers, and it works great.
but wouldn't vy stay the same if there is an obstacle (i.e. a platform or the floor)? and when you fall off of something, wouldn't vy become greater until it hits something? btw, vy stands for the Y Vector right?
vy would be vertical velocity, and it would = 0 if there was no way for the object/player to go down.

*peace*

Meg.
If course, x = x + vx and y = y + vy are performed only when the player is able to move, i.e. no obstacles in the direction it advances. And Meg's correct: When that happens, v's are reset. I forgot to mention that.l
You can get gravity formulas from GORILLAS, which you can get from QBNZ. But although they are correct for predicting gravity, they are slower.
thanx, i'll have to check that out...