5.1.4 - Multiple objects movement

Starting from the previous script, that we have created a white moving rectangle and a red frame, can you add code for the red frame to move and bounce to the edges of the screen?

As you can see the code is starting to be complicated so writing comments and keep the code tidy helps.




If you have an error in your script you can download the code from here 

As you can see we managed to bounce two rectangles but we wrote everything twice (WET) which is against our programming principles: Don't repeat Yourself (DRY).