Bounce off the edge
Move the sprite forward every tick and flip its direction automatically when it reaches a stage edge.
whenGreenFlag(() => { forever(() => { move(5); ifOnEdgeBounce(); });});The sprite travels in its current direction and reverses when it hits a wall.
Change 5 to a larger number for faster movement.
Functions used
Section titled “Functions used”whenGreenFlag— run code when the green flag is clickedforever— repeat a block of code indefinitelymove— move forward by a number of stepsifOnEdgeBounce— bounce off the edge of the stage if touching itsetRotationStyle— set how this sprite rotates when its direction changes