Help with gravity please
-
- Posts: 1
- Joined: July 19th, 2012, 9:10 pm
Help with gravity please
hello every1, i am wasting alot of time trying to fix gravity to a 2d platformer, can any1 walk me trough it ?
Re: Help with gravity please
Hey!
Do you have any started project yet?
I am only a beginner but one way should probably be that, in every update of the Player, just set y++; that would make the Player fall down with 1 pixel every update intill he either reaches a ground or fall off the screen..
someone else might have an more advanced and better way.
but this could be one way.
good luck
Do you have any started project yet?
I am only a beginner but one way should probably be that, in every update of the Player, just set y++; that would make the Player fall down with 1 pixel every update intill he either reaches a ground or fall off the screen..
someone else might have an more advanced and better way.
but this could be one way.
good luck
Re: Help with gravity please
Yep, a pseudo code would be; if character has not collided with terrain, then character y will be reduced by gravity.
If you wanted it more realistic, something like an accelerating hyperbola gravity might be good.
If you wanted it more realistic, something like an accelerating hyperbola gravity might be good.
ʕ •ᴥ•ʔ
Re: Help with gravity please
Lux, for how long have you programmed?
just think some of your uploaded things on the forum is great, and i learn alot from them and learn even more from trying to modify for own games.
the square game with dust is awsome! can't stop playing it
just think some of your uploaded things on the forum is great, and i learn alot from them and learn even more from trying to modify for own games.
the square game with dust is awsome! can't stop playing it
Re: Help with gravity please
About 2 to 3 years of Visual basic. But there I never really learned to code anywhere properly so I pretty much learned the syntax and had to figure out most of the stuff by my self. And it was mostly application programming, rather than game programming.
Actual, and proper, game programming I have done since I found chili's tutorials. So that's about exactly 3 months of c++ I've been learning now.
Actual, and proper, game programming I have done since I found chili's tutorials. So that's about exactly 3 months of c++ I've been learning now.
ʕ •ᴥ•ʔ
- npissoawsome
- Posts: 114
- Joined: June 8th, 2012, 3:01 pm
Re: Help with gravity please
What I do is check if the player is actually above the floor, and if so get some proposed co-ordinates (his position minus some value on the y axis) and check to see if that position collides with anything, if it does, nothing happens, if it doesn't collide, the character goes to these proposed co-ordinates