Sine Wave
theory

Algorithm to take our sine wave from one side of the Scratch screen to the other, on repeat:
forever: let Θ = (angle) y = (amplitude) × sin Θ, for: -(screen_width)° ≤ Θ ≤ (screen_width)° if angle > screen_width, let Θ = -(screen_width)
implementation

implementation v2
with alternating speeds, start positions and amplitudes:
questions
1. Variable effectsExplain what happens if you increase or decrease the initial variables:
screen_width
amplitude
speed
angle
2. Gamify
Use this sine wave as patrol code for an emeny in a game of your choosing.