[Tutorials] Making a simple 2D physics engine

Showcase your libraries, tools and other projects that help your fellow love users.
User avatar
HugoBDesigner
Party member
Posts: 403
Joined: Mon Feb 24, 2014 6:54 pm
Location: Above the Pocket Dimension
Contact:

[Tutorials] Making a simple 2D physics engine

Post by HugoBDesigner »

Hello again, guys! So, after finishing my simple physics engine, I decided I could make some tutorials to show to other physics-engine beginners that making a simple 2D physics engine isn't as complicated as it looks. I've been avoiding doing one for a few years, but after LÖVE Jam #2 I decided to give it a try, and turns out that I was wrong about thinking they were over complicated.

I made two tutorials (I'll still make the last one in a short future) and tried to make them as simple as I could. I made them illustrated and showcased some variants of concepts, so people could understand more easily the concepts of 2D physics and come up with their own methods of doing it.

If you guys are interested, have any ideas, suggestions or feedback about these tutorials (or the future one), please let me know.

Without further ado, here are the tutorials:

Making a Simple 2D Physics Engine - Part 1
  • Content: Collision detection/handling.

Making a Simple 2D Physics Engine - Part 2
  • Content: Gravity, friction, speed, masks and other global/local concepts.

Making a Simple 2D Physics Engine - Part 3
  • Content: Drawing objects and optimizing your engine.

Physics Simulator game
  • Content: Multiple physics-handling methods in the same game, small "playground" to test object collisions, in-game settings for variables and methods as shown in the tutorials

Tutorial snippets
  • Content: Slopes, player movement, triggers, environmental physics, custom properties, etc.

  • Nothing here is confirmed or unconfirmed: These snippets will be some extra posts related to specific topics, without schedule or specific topics. So, naturally, suggestions are welcome!
Last edited by HugoBDesigner on Fri Dec 12, 2014 11:57 am, edited 2 times in total.
@HugoBDesigner - Twitter
HugoBDesigner - Blog
User avatar
HugoBDesigner
Party member
Posts: 403
Joined: Mon Feb 24, 2014 6:54 pm
Location: Above the Pocket Dimension
Contact:

Re: [Tutorials] Making a simple 2D physics engine

Post by HugoBDesigner »

Quick update: added "copiable" text to the tutorial, so people following it don't need to rewrite what's in the images :)
@HugoBDesigner - Twitter
HugoBDesigner - Blog
User avatar
Zilarrezko
Party member
Posts: 345
Joined: Mon Dec 10, 2012 5:50 am
Location: Oregon

Re: [Tutorials] Making a simple 2D physics engine

Post by Zilarrezko »

congragulations Hugo, you've single handedly solved about 25% of all questions asked on the Löve2D forum! How do you feel?
User avatar
HugoBDesigner
Party member
Posts: 403
Joined: Mon Feb 24, 2014 6:54 pm
Location: Above the Pocket Dimension
Contact:

Re: [Tutorials] Making a simple 2D physics engine

Post by HugoBDesigner »

Zilarrezko wrote:congragulations Hugo, you've single handedly solved about 25% of all questions asked on the Löve2D forum! How do you feel?
Heheh, I actually feel quite happy that I could help. I remember a few months/years ago having too many problems understanding these concepts, but I had a lot of help from a nice user called Qcode (the guy who made Mari0 online mod) and a few other users from the Stabyourself forums. Now that I'm very used to LÖVE, I decided that I should try to help other people too, so knowing that I'm helping makes me really glad :awesome:
@HugoBDesigner - Twitter
HugoBDesigner - Blog
User avatar
Zilarrezko
Party member
Posts: 345
Joined: Mon Dec 10, 2012 5:50 am
Location: Oregon

Re: [Tutorials] Making a simple 2D physics engine

Post by Zilarrezko »

HugoBDesigner wrote:
Zilarrezko wrote:congragulations Hugo, you've single handedly solved about 25% of all questions asked on the Löve2D forum! How do you feel?
Heheh, I actually feel quite happy that I could help. I remember a few months/years ago having too many problems understanding these concepts, but I had a lot of help from a nice user called Qcode (the guy who made Mari0 online mod) and a few other users from the Stabyourself forums. Now that I'm very used to LÖVE, I decided that I should try to help other people too, so knowing that I'm helping makes me really glad :awesome:
You should, and I hope this gets recognition because as it seems. A lot of people will need this. Good luck man, and I'll stay tuned.
User avatar
Roland_Yonaba
Inner party member
Posts: 1563
Joined: Tue Jun 21, 2011 6:08 pm
Location: Ouagadougou (Burkina Faso)
Contact:

Re: [Tutorials] Making a simple 2D physics engine

Post by Roland_Yonaba »

Hmm... I took a quick glance at the OP, and in my humble opinion, you should not start explaining the inners of a physics engine starting from collision detection and resolution. It is an advanced concept.
User avatar
HugoBDesigner
Party member
Posts: 403
Joined: Mon Feb 24, 2014 6:54 pm
Location: Above the Pocket Dimension
Contact:

Re: [Tutorials] Making a simple 2D physics engine

Post by HugoBDesigner »

Roland_Yonaba wrote:Hmm... I took a quick glance at the OP, and in my humble opinion, you should not start explaining the inners of a physics engine starting from collision detection and resolution. It is an advanced concept.
Actually, I made it in a way that it is pretty easy to understand. If you go to the blog post, you'll see that, not only I explained it in a simple way, but I also gave examples to illustrate some concepts. Also, I'm explaining simple physics, so there isn't anything complex like non-rectangular collision, rotation, mass, etc. The first tutorial teaches only collision detection :)

On another note: If there's any moderator reading this, in which forum would this thread fit better? I put it in Projects and Demos because it is a small tutorial project of mine, but maybe it'd make more sense in either Support and Development or General.
@HugoBDesigner - Twitter
HugoBDesigner - Blog
User avatar
soulaymenc
Prole
Posts: 36
Joined: Thu Jul 11, 2013 2:03 pm
Contact:

Re: [Tutorials] Making a simple 2D physics engine

Post by soulaymenc »

I am working on a game engine right now, and this gives me many inspiration, I will follow your tutorial and hope I wont end up just copy pasting xD

Thank you very much :)
This world is so strange.
User avatar
HugoBDesigner
Party member
Posts: 403
Joined: Mon Feb 24, 2014 6:54 pm
Location: Above the Pocket Dimension
Contact:

Re: [Tutorials] Making a simple 2D physics engine

Post by HugoBDesigner »

soulaymenc wrote:I am working on a game engine right now, and this gives me many inspiration, I will follow your tutorial and hope I wont end up just copy pasting xD

Thank you very much :)
You're welcome, I'm glad I could help :D

I guess I should also let you guys know that I'm already working on the part 2 of the tutorial, so you should expect it to be released pretty soon :)
@HugoBDesigner - Twitter
HugoBDesigner - Blog
User avatar
Tjakka5
Party member
Posts: 243
Joined: Thu Dec 26, 2013 12:17 pm

Re: [Tutorials] Making a simple 2D physics engine

Post by Tjakka5 »

EDIT: Nevermind, got it fixed

Great code, works like a charm. Really want to make a game with this now :3
Post Reply

Who is online

Users browsing this forum: No registered users and 56 guests