[Tutorials] Making a simple 2D physics engine
Re: [Tutorials] Making a simple 2D physics engine
Thanks! Best tutorials about 2D physics!)
My library for easy saving Slib! Try this! Now you can encrypt your save!
- Drop of light LD#30
- OUTRANGE LD#31
(Sorry for my english. I learn it myself, and I don't have enough experience)
- Drop of light LD#30
- OUTRANGE LD#31
(Sorry for my english. I learn it myself, and I don't have enough experience)
- 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
Thank you very much, I really appreciate itSnuux wrote:Thanks! Best tutorials about 2D physics!)
Also, the reason why it took me forever to answer this is because I was waiting to have the third tutorial, in order to have more content in the same post. Naturally, as a huge procrastinator that I am, it took several hundreds of years, but it's finally here!
I'm not posting a link here because I want you guys to check out the main post. There are some new information I want you guys to know about, so go check that out! Also, MANY, MANY THANKS for your support and feedback! In less than a month the Physics Tutorial post was the most visited post of my blog, and with your guys' boost, my blog has almost 10.000 views! So, from the depths of my heart, THANK YOU!
Re: [Tutorials] Making a simple 2D physics engine
Great work on the tutorials, I can see that you put in a lot of effort there.
Just have a small suggestion regarding the following piece of code:
It clamps each axis separately which means that diagonally moving objects can move faster.
here is an alternative approach:
Again, sorry to nitpick, love the tutorials!
Just have a small suggestion regarding the following piece of code:
Code: Select all
obj1.speedx = math.min( math.max(obj1.speedx, -maxspeed), maxspeed)
obj1.speedy = math.min( math.max(obj1.speedy, -maxspeed), maxspeed)
here is an alternative approach:
Code: Select all
local d = math.sqrt(obj1.speedx*obj1.speedx + obj1.speedy*obj1.speedy)
if d > maxspeed then
local n = 1/d * maxspeed
obj1.speedx, obj1.speedy = obj1.speedx * n, obj1.speedy * n
end
- 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
I usually do that way because in most games I don't mind about diagonal speed, but your approach is really nice and clever, thanks for sharing! I'll make sure to include it in the corresponding part of the tutorial and give credits for you.
Also, it's not nitpicking, as I said in the main post any suggestions are welcome, and having multiple methods for more things is always nice, so thank you very much
Also, it's not nitpicking, as I said in the main post any suggestions are welcome, and having multiple methods for more things is always nice, so thank you very much
Who is online
Users browsing this forum: Ahrefs [Bot] and 4 guests