QB CULT MAGAZINE
Issue #8 - January 2001
Physics Engines Pt. 2
By QbProgger <qbprogger@tekscode.com>
Figher Game In A Nutshell
[Editor's Note: Sorry this is incredibly small. QbProgger put
this together really quickly, since he was quite busy in December.]
- Create 2 rather large objects
- Set a gravity on the y axis (gravity in real life is -9.8m/s so
adjust for the character's height and the framerate of your engine)
start loop
- If the space bar is hit, set y acceleration to a number that seems
reasonable. IF it's too high, the character will go offscreen, too low,
the character will hardly hop. Experiment based off of your settings!
- If the object's 2 bounding boxes collide, check to see if each
object is in an attacking state. If both aren't they just collide with
each other causing no damage. Otherwise, do damage accordingly, and do
a pixel-perfect detection if you know how.
- If one player is dead, round's over exit loop, otherwise keep looping
Simple enough, eh? :)
Next QBCM will feature a demo of this fighting game structure as
well as an explanation of how to make a sidescroller with a physics
engine!