There are a few different physics engines that programmers use now for their games. There are 2 main physics engines that programmers use: Havok, and Math Engine.
A Physics Engine is the code that game companies buy or Build to put in their code. The code is already written and they just have to implement the code in their program.
The thing about Physics in video games is that none of it has to be realistic. Most of the physics in older games aren't close to being realistic for there were way too many equations the program would have to solve and it would slow it down. There are arguments that go on that unrealistic games are more fun, or realistic games are more fun.
postion.y = 0; (Or wherever floor is)
Joe.velocity.y = 0;
Joe.acceleration = 10;
Joe.jumping = NO;
Loop
If (jump key is pressed)
{
Joe.velocity.y = 100;
Joe.jumping = YES;
}
if (Joe.jumping == YES) /* Move Joe if we are jumping */
{
Joe.velocity.y = Joe.velocity.y - Joe.acceleration
Joe.postion.y = Joe.postion.y + Joe.velocity.y
}
if (Joe.postion.y <= 0) /* Check to see if Joe has hit floor */
{
Joe.velocity.y = 0;
Joe.jumping = NO;
}
End Loop
this code will continue to run until joe hits the floor after the jump key is pressed.
The loop means that it will continue to run the statements on the inside of the loop until the loop fails in its test.
so the program will show this each times it loops.
Loop0 : Joe.velocity.y = 0 Joe.postion.y = 0
Loop1 : Joe.velocity.y = 100 Joe.postion.y = 100
Loop2 : Joe.velocity.y = 90 Joe.postion.y = 190
Loop3 : Joe.velocity.y = 80 Joe.postion.y = 270
Loop4 : Joe.velocity.y = 70 Joe.postion.y = 340
Loop5 : Joe.velocity.y = 60 Joe.postion.y = 400
Loop6 : Joe.velocity.y = 50 Joe.postion.y = 450
Loop7 : Joe.velocity.y = 40 Joe.postion.y = 490
Loop8 : Joe.velocity.y = 30 Joe.postion.y = 520
Loop9 : Joe.velocity.y = 20 Joe.postion.y = 540
Loop10: Joe.velocity.y = 10 Joe.postion.y = 550
Loop11: Joe.velocity.y = 0 Joe.postion.y = 550
Loop12: Joe.velocity.y = -10 Joe.postion.y = 540
Loop13: Joe.velocity.y = -20 Joe.postion.y = 520
Loop14: Joe.velocity.y = -30 Joe.postion.y = 490
Loop15: Joe.velocity.y = -40 Joe.postion.y = 450
Loop16: Joe.velocity.y = -50 Joe.postion.y = 400
Loop17: Joe.velocity.y = -60 Joe.postion.y = 340
Loop18: Joe.velocity.y = -70 Joe.postion.y = 270
Loop19: Joe.velocity.y = -80 Joe.postion.y = 190
Loop20: Joe.velocity.y = -90 Joe.postion.y = 100
Loop21: Joe.velocity.y =-100 Joe.postion.y = 0
You notice once it starts after the jump key is pressed that he will go up to 100 units and continue to go up until his velocity equals zero. Then after velocity is less than zero he will go down until he hits the ground.
Rigid body physics is one the more complex equations that games have to go through. A deformable body can be modeled as a system of point masses connected by springs. The bodies can be curve masses(e.g., hair or rope), surface masses (e.g., cloth or the surface of a body of water), or volume masses (e.g., a...