Jump to content
  • Advertisement
Sign in to follow this  
Canning

2d physics

This topic is 2521 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello all.

I am wanting to create a 2d space action game similar to Subspace or Star Sonata.
Just to get me started, I am wondering if there is any 2d physics examples out there for me to have a look at? I am wanting to do this in VB2010

I would love to be able to use mouse clicking as well. So that I can click a destination on my 2d map, and the ship will turn and move towards this destination, taking into account its physics variables.

I used to have a directx example of this called shpshoot.zip, but have lost it. Does anyone have this example or can help me with some code?

thanks ppl

Canning

Share this post


Link to post
Share on other sites
Advertisement

I am wanting to create a 2d space action game similar to Subspace or Star Sonata.
Just to get me started, I am wondering if there is any 2d physics examples out there for me to have a look at? I am wanting to do this in VB2010


I recommend reading:Game Physics Engine Development
And there are also some other really good physics articles Here.
I read them, it took awhile but it was worth it.


But if you just want arcade physics those books/articles might not be necessary.
If you do want arcade physics, then all you need is a good knowledge of vector math and trigonometry.



Share this post


Link to post
Share on other sites
The 2d physics engine I use is Chipmunk-physics. You shoudl check it out.

The other popular 2d physics engine in Box2D, although I haven't used it. From the little research I've done, Chipmunk is better.

Share this post


Link to post
Share on other sites
If you have taken a physics class then it isn't to complex, you just apply what you learned in the class to programming. AKA position is changed through velocity.

If you haven't taken a physics class you definitely want to learn math vectors
http://www.khanacademy.org/video/introduction-to-vectors-and-scalars?playlist=Physics


After that you want to learn what velocity and acceleration are
http://www.khanacademy.org/video/displacement-from-time-and-velocity-example?playlist=Physics and from this click next and get to acceleration.


In order to create a physics simulation you basically give every object a velocity. To calculate the next position you multiply the velocity X or Y component by the change in time and add that to the objects current object. In order to create the curve that you want to make you would probably have to give the object an acceleration towards the destination point and as long as you update the acceleration every iteration your object will create a curve towards the object.

How you rotate your object is up to you, however I think I explained the 2D physics required pretty well. :D Good luck!

Share this post


Link to post
Share on other sites
OK, I have found my way to control my ship.

I am now after a way to move my ship to a destination x and y coordinate.

Here are the important variables:

Const PI = 3.14159 'Mmmm.. Pi
Const ACCEL = 0.1 'Rate of increase of speed
Const ROTATION_RATE = 15 'Rotation speed
Const SHIP_RADIUS = 10 'Distance from center of triangle to any vertex
Const MS_DELAY = 25 'Milliseconds per frame (25 = 40 frames per second)

Dim msngFacing As Single 'Angle the ship is facing (ok, ok, it's a triangle, not a ship! Shut it!)
Dim msngHeading As Single 'Current direction in which ship is moving
Dim msngSpeed As Single 'Current speed with which ship is moving
Dim msngX As Single 'Current X coordinate of ship within form
Dim msngY As Single 'Current Y coordinate of ship within form


Can I please have some help with this?

thanks

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!