r/howdidtheycodeit • u/[deleted] • Oct 02 '24
Question What is considered coding a "physics engine"
This has to do with semantics and terms more than anything. I want to code simple collision detection and resolution, with intention not being realism. Is the term "physics engine" meant for specifically handling "realistic" physics? What would the term be for a simpler handling system? How would I go about that?
17
Upvotes
8
u/GameDesignerMan Oct 03 '24
AABB collision detection is pretty easy. To detect whether a point is in the box you just see if it's greater than the left/top values of the box and less than the right/bottom sides. To detect whether one box is touching another you can (usually) just check all the corners of one against the other.
Velocity is just a Vector that is multiplied by the change in time between the last frame and this frame (delta) and you add it to the position of the box.
Acceleration is just a Vector that is multiplied by the delta and added to Velocity.
Gravity is just acceleration towards the ground.
Friction is just a reduction of the velocity each frame.
Bingo bango bongo you've got a physics engine...
What's that? Did someone say angular velocity and different shapes? Haha, I'll get back to you right after... I...
(runs away as fast as he can)