Jump to content

How would I go about adding a wind element to my game?


StephenDunne
 Share

Recommended Posts

Well the first thing that comes to my mind is a system like the following:

 

Let's suppose that your helicopter can only fly in one direction (to the right).

Then, in the update loop you can decrease the X value of the sprite.

When the player presses the RIGHT key, the X value of the sprite increases (the speed value must be higher than the 'strength of the wind').

 

This way if the player does nothing the sprite will move backwards. But if it presses the RIGHT key the sprite will try and move forward slowly against the wind. You should be able to adapt the system to give a boost or reduce the speed of the sprite depending on the wind direction and the movement direction.

 

Warning: this idea has not been tested and anything could go wrong.

 

EDIT:

Tested: http://codepen.io/anon/pen/RNLzEP

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...