I am trying to accomplish a gravity, where airtime is included, and also acceleration.
I have tried using usual gravity, which looks something like this:
velocity += gravity * dt;
position += velocity * dt;
This would probably work good enough for a normal platformer game, but I am trying to make a game inspired by "The helicopter game", where you have to navigate through a tunnel, without touching the walls.
what I want to do different, is that I want to be able to save up speed on the way down, which will be used on the way up again, so I will have some acceleration at the beginning.
I also want some kind of airtime, so when you hit the top it would not force you down as fast as It would, if I had used the gravity from the code sample.
This image illustrates the curve I would like to have:
Please note that the whole controlling is done by one key, so for example you would fly up if you held down space, and dive if you released it.
The character also never moves left or right, since it will have a static X position on the screen, so vectors can't be used.
I have spent hours trying to make it work, but with no success. I have also tried searching on the internet, but without any luck.
The game "Whale Trails" got the gravity I kind of want.
Here is a link for a video of the game: http://www.youtube.com/watch?v=5OQ0OWcuDJs
I'm not that big of a physics guy, so it would be cool if you could give an example of the actual code
I hope anyone can help me figure this out.