Hello,
I have been using the box2D library for about five weeks now. I am really enjoying programming with the library it's fantastic.
I am however very inexperienced with physics programming. I am having trouble solving a problem. I am creating a game. It is a top-down space shooter. Whilst I can get the physics engine working and create bodies I am having a little trouble getting those bodies to behave correctly.
Firstly what I have got working is the ship's rotation. The ship rotates if the player holds down the left or the Right arrow. I am using the applyTorque with a good amount of success. I was able to reverse engineer the apply force test to achieve my desired result.
I run into problems when applying force to the body. Basically when a user presses the up key I want the ship to travel in the direction it is facing. This has proved difficult to me. I have looked through the tests, the tutorials and the API as well as the wiki. The apply force test is the only example that I can find that relates to what I want to do. I have copied the code from this example and attempted to tweak it however I have been unsuccessful. The ship moves but it does not move in that direction relative to the rotation is facing. I am a little bit stuck with this problem.
Can someone point me in the right direction to an example already out there? An example aside from what is already in the testbed. Is what I am trying to achieve easy? Any feedback would be appreciated. Thanks for taking the time to read my post.
I have been using the box2D library for about five weeks now. I am really enjoying programming with the library it's fantastic.
I am however very inexperienced with physics programming. I am having trouble solving a problem. I am creating a game. It is a top-down space shooter. Whilst I can get the physics engine working and create bodies I am having a little trouble getting those bodies to behave correctly.
Firstly what I have got working is the ship's rotation. The ship rotates if the player holds down the left or the Right arrow. I am using the applyTorque with a good amount of success. I was able to reverse engineer the apply force test to achieve my desired result.
I run into problems when applying force to the body. Basically when a user presses the up key I want the ship to travel in the direction it is facing. This has proved difficult to me. I have looked through the tests, the tutorials and the API as well as the wiki. The apply force test is the only example that I can find that relates to what I want to do. I have copied the code from this example and attempted to tweak it however I have been unsuccessful. The ship moves but it does not move in that direction relative to the rotation is facing. I am a little bit stuck with this problem.
Can someone point me in the right direction to an example already out there? An example aside from what is already in the testbed. Is what I am trying to achieve easy? Any feedback would be appreciated. Thanks for taking the time to read my post.