Write a simple 2d physics application

Started by
2 comments, last by IsItSharp 8 years, 11 months ago

Hi,

I thought about writing a small javascript application about physics, maybe something like this:

It is kind a hard to find any tutorials about this topic because most results for javascript physics just shows complete frameworks or toolkits and i want to write it myself.

So my question is:

Where should i start?

Advertisement

You don't mention what the intent of your effort is to be. Are you looking to learn about javascript? physics? Or, do you know all about those, and you're just looking to code something? Or, are you just looking for something to take up time? happy.png


results for javascript physics just shows complete frameworks or toolkits and i want to write it myself. So, Where should i start?

Depends on how many applications you've written already. If you have your own framework, the benefit is that you're familiar with it - just starting adding pieces to that.

If you haven't successfully written a framework or engine before, and you're not looking to just waste some time, study other frameworks - see how they're organized, what features they offer that you do or don't want to incorporate, learn coding practices from them. Assuming you're not looking to just waste some time, don't reinvent the wheel. You don't have to use exactly what others have done. Why you're hesitant to learn from others isn't clear.

In either case, from the looks of the video you posted, you're going to need some sort of collision detection in addition to the physics. Unless you understand all the interactions that appear in the video (e.g., shape drawing, collision detection, force and torque, friction, etc.), take a few days to brush up on those principles.

Then - draw something. Make it move. Figure out how to determine if a moving object has collided with a stationary object. Figure out how to determine if a moving object has collided with another moving object. That's the collision part. Then determine how you want the object to behave when it collides with another object. That's the physics part.

Continue the process based on your experience and intelligence. happy.png

Please don't PM me with questions. Post them in the forums for everyone's benefit, and I can embarrass myself publicly.

You don't forget how to play when you grow old; you grow old when you forget how to play.

try to find 2d physics tutorials in general, not focused on java script, you'll find more. while most will probably use other languages, the knowledge they share is usually quite generic and you can apply it in java script.

You don't mention what the intent of your effort is to be. Are you looking to learn about javascript? physics? Or, do you know all about those, and you're just looking to code something? Or, are you just looking for something to take up time?

I want to learn mostly about physics and push my javascript skills.

Continue the process based on your experience and intelligence.

thanks for your post. I did a little bit of research and build a very simple program which just checks for intersection :D

https://jsfiddle.net/bwvv5hoy/1/

This topic is closed to new replies.

Advertisement