Random Movement

This code snippet makes a sprite move randomly around the screen.

It works by using a forever loop, repeating these 3 steps: It will move a random amount of steps (1-10), turn clockwise a random amount -20 to 20 degrees. And if it hits an edge, it will bounce off.

Code can be found here:


Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top