Ship mouvement


Hello community!

I'm excited to share with you the latest development in my game Ship Survivors. In this devlog, I'll be discussing the movement of the player's ship in the game.

As many of you know, the movement of the ship is an integral part of the gameplay in Ship Survivors. The player must navigate through the levels and shoot down enemy ships in order to survive. To make this experience even more enjoyable, I've been working on refining the controls of the ship.

Here's a look at the updated code that implements the movement of the ship:

In this code, we first declare constants for the speed of the ship (SPEED), the friction that slows the ship down (FRICTION), and the maximum speed that the ship can reach (MAX_SPEED).

Next, we use these constants to determine the movement of the ship. The ship's speed decreases over time as a result of friction, represented by the line let temp_vy = this.vy * FRICTION; and let temp_vx = this.vx * FRICTION;.

Then, depending on which keys are being pressed (up, down, right, or left), the ship's vertical velocity (temp_vy) and horizontal velocity (temp_vx) are adjusted accordingly.

Finally, the code checks to ensure that the ship's speed does not exceed the maximum speed, by comparing temp_vx and temp_vy with MAX_SPEED and limiting their values if necessary.

I hope you're as excited as I am to see these changes in action! Stay tuned for more updates on Ship Survivors.

Play the game here: https://caprog.itch.io/ship

Leave a comment

Log in with itch.io to leave a comment.