Create a random sprite animation. The sprite should start in a random location anywhere in the window. Run script multiple times to verify that the sprite can start anywhere on the screen. The sprite should move in a random direction with a random speed. Run the script multiple times to verify that the sprite can move in any direction.
The sprite only moves for a little bit before it moves off of the screen forever. Modify the random sprite animation so that the sprite bounces off all of the edges of the screen and therefore never leaves the screen. Note, the sprite should not have a new random velocity every time it bounces.
To create the bounce animation, change the velocity of the sprite, so it looks like it bounced, if the sprite has reached the edge of the screen. The sprite’s velocity after it hits the edge of screen should be calculated so that the direction, but not the speed of the sprite changes. The calculation is different for each edge of the screen. For example, if the sprite hits the bottom of the screen:
The sprite’s x speed before hitting the edge and after hitting the edge are the same. The sprite’s y speed changes, but note that the absolute value of the sprite’s y speed before and after hitting the edge are the same.
Submission
Please show your source code and run your scripts for the instructor or lab assistant.