Undertaking the new project, Project GearJump, whose central mechanic is jumping lead me to a mad dash to learn as much as possible about that mechanic in other video games. It seems that this topic can be way broader than I initially thought!
This post will cover the path I took and some of the things I learnt. Instead of going in depth into anything, I will provide the resources I used as they do a perfect job of explaining everything already!
The things and examples you will see are written in various languages but just know that you can apply all the principals you see to most if not all programming languages.
Before we get into it!
Just to catch everyone up to speed a standard jump within a video game involves a starting location, a jump velocity and gravity.
It works by taking your x, y location and applying your jump velocity to it all the while applying your gravity to your velocity.
This in tandem with collision will simulate jumping and landing from and onto a surface.
Here is the first resource, it goes over fixed height jumps and variable height jumps which are two different styles of the basic jump!
Make sure to look at answer 2s working example.
Getting into it!
Reading a book called the nature of code was a great idea, essentially it’s a physics book that explains its implementation within code. The chapters about vectors and forces opened my eyes to how you can effectively implement a jump while considering other forces and mass. The code is all in a language called processing but as I mentioned above, this stuff is language agnostic and can be applied to any language.
Oh, we in there!
Looking Into the jumps of other games is as important as it is interesting! For instance, did you know that in Mario, gravity gets applied at a much weaker rate on Mario’s ascent and when Mario reaches the apex of his jump a stronger gravity gets used? I didn’t, and without this information, I wouldn’t even have thought to do that!
It is oddly easy to find a breakdown of the jump mechanics from a notable game (especially if you are Mario), but the hard part is finding resources that cover and compare the jump mechanics of multiple games. On top of this, some resources go into too much depth, which is fine, but probably not for everyone so here are a few links that I found to be the most useful!
(Mario Bros 3 jump mechanics) http://meyermike.com/wp/?p=175
(super meat boys jump mechanics) http://meyermike.com/wp/?p=160
This page used to have a working example of jump mechanics from multiple games that you could switch between and test but it is not up and running at the moment. The comments on this page are still very useful though.
In fact, this person’s blog is just generally good, you might find other useful things here too!
(Covers the jump mechanics of 5 games) http://www.gatheryourparty.com/2015/01/28/5-games-5-jumps/
(This video provides allot of food for thought!) https://www.youtube.com/watch?v=yuRRPT-Isp4
Coming back out!
After taking in all this information I was well equipped and ready to take on this large hacking process to find and fine tune the values that equate to a good feeling jump. Though I believe what I have right now feels good, as the project develops I know I will constantly be looking back at my jump code to make sure the jump mechanic not only feels great but functionally fits in well with the greater games level design.