Atari Asteroids Ship Spin with Box2d

Hi all, I’m making an Atari Asteroids replica with box2D. I have done some other little games in Corona, but without Box2d, so I really would use it for this. I have tried different ways, but when I set a max speed for the ship, or when I use damping, my ship lose the abitilty to go forward making spin while boost is on. I’m making this remake watching the atari asteroids version at this adress:

https://www.atari.com/arcade#!/arcade/asteroids/play (work only with internet explorer)

Here two video of the spin that I would to replicate:

http://youtu.be/rOHWCaymUDg

http://youtu.be/KD7Lps_EePA

Here’s a video from my game, recorder from android tablet, poor quality, sorry.

https://www.youtube.com/watch?v=SPsJASzJ_zo

When I turn right or left with boost activated, it simply describes a circle, I need the spiral move.

Tips?

Hi @marcoguerrera84,

As your next experiment, I would try the following:

  1. At any time when the boost/thrust button is pressed down, gather the angle (rotation) of the ship. Using basic vector math, convert this angle to X/Y vector values, and then apply that force to the ship (from behind it actually), focusing the force on the body’s center point. (http://docs.coronalabs.com/api/type/Body/applyForce.html)

  2. Turn off all linear damping. The ship is in space, so it shouldn’t slow down.

  3. Set the ship to fixed rotation (.isFixedRotation = true). The goal here is to allow the player to turn the ship (via one of the turn buttons), but not let Box2D spin it around when force is applied.

  4. When the player presses one of the turn buttons, just add or subtract a certain small number of degrees from its angle, making it turn by code, not by Box2D rotation means.

Best regards,

Brent

I tried to improve the code by following your advice, but the result does not satisfy me yet. I do not understand how to replicate the movement of the original game …

http://youtu.be/EkuMfnHWa9k

Hi @marcoguerrera84,

It looks like it’s getting closer to a “realistic” ship movement. You’ll need to continue working on it, because there are simply too many options and methods for physics, and ultimately you’ll need to find a solution that mimics the original game. That is definitely possible, but it may take some time to find the perfect combination.

Take care,

Brent

Hey OP,

Maybe you could disable the thrust when you are turning?

Hi @marcoguerrera84,

As your next experiment, I would try the following:

  1. At any time when the boost/thrust button is pressed down, gather the angle (rotation) of the ship. Using basic vector math, convert this angle to X/Y vector values, and then apply that force to the ship (from behind it actually), focusing the force on the body’s center point. (http://docs.coronalabs.com/api/type/Body/applyForce.html)

  2. Turn off all linear damping. The ship is in space, so it shouldn’t slow down.

  3. Set the ship to fixed rotation (.isFixedRotation = true). The goal here is to allow the player to turn the ship (via one of the turn buttons), but not let Box2D spin it around when force is applied.

  4. When the player presses one of the turn buttons, just add or subtract a certain small number of degrees from its angle, making it turn by code, not by Box2D rotation means.

Best regards,

Brent

I tried to improve the code by following your advice, but the result does not satisfy me yet. I do not understand how to replicate the movement of the original game …

http://youtu.be/EkuMfnHWa9k

Hi @marcoguerrera84,

It looks like it’s getting closer to a “realistic” ship movement. You’ll need to continue working on it, because there are simply too many options and methods for physics, and ultimately you’ll need to find a solution that mimics the original game. That is definitely possible, but it may take some time to find the perfect combination.

Take care,

Brent

Hey OP,

Maybe you could disable the thrust when you are turning?