Game Development Reference
3. We use point in direcion () to make the sprite face left; fill in value -90 .
4. Then we add a repeat () loop that will run 500 imes.
5. This patern requires a slower horizontal speed, so we move speed / () steps
each cycle of the loop.
The finished script will look like the following screenshot:
Now we get to the interesing part. We will use a sine wave formula to determine the
verical posiion of the sprite based on its horizontal posiion. This is why we needed to
slow down the horizontal movement. At regular speed, the movement would be way too
fast and bouncy.
1. So after moving horizontally, we use set y to () . This slot will be filled with a formula
that is constructed from different parts.
2. First, we take the x posiion and place it in the let slot of the () * () block. In the
right slot, we enter the value as 0.5 . The resuling number determines how
frequently the sprite completes a full wave (up-down and back to center). The
higher the number, the shorter the wave.
3. Then we take this result and muliply it by 4 (using muliply ). This number
determines the overall speed of the wave moion. It's an opional number.
It's not necessary to complete the formula, but it gives us more control.
4. Then we use the mathemaical sin funcion on this result. This is what efecively
causes the wavy patern.
5. Finally, we muliply the whole by 150 (using muliply ). This part determines the
amount by which the wave deviates from the center line. This number is literally
the maximum verical distance from the center line.