At 8/3/09 04:54 PM, JoeyCentral wrote:
Why do I have to learn what gravity is JUST TO MAKE A GUY FUCKING JUMP?! I never learned physics, so it's kind of fucking hard to do advance shit like that. Also, I can't make something move without a proper math formula, which is bull shit! I mean, I didn't even do Geomerty yet, and yet it's a necessity to know trigonometry? Yeah, please tell me there's an alternative to learning this crap cuz I wanna know how to code.
you don't have to know physics to understand the concept of gravity, you live in a world with it
what happens when you jump? you go up until the amount of energy used is no longer sufficient to escape the earth's gravitational pull, then you come back down.
Let's say in a game, when you jump, the character starts by moving upwards at 10px/frame. Obviously this will change over the course of the jump- if it didn't your character would just float up and away forever. So once the jump starts, just start subtracting an arbitrary amount each time to represent gravity pulling them back down. So for each frame let's say you subtract .1 px. Your speed will slowly work it's way down to 0 (the height of the jump) and into the negative, bringing you back down. When you detect touching the ground reset your speed var and have it ready for the next jump.
this is 'fake physics' because it doesn't use any real formulas and isn't based on the actual laws of gravity. It's just imitating them to look believable.
you'll need to know a little trig if you want to work with rotations, angles, arcs, curves, etc. you don't need to take a class in it though, you can just become familiar with some of the formulas to take care of the basics.