Modify the bouncing ball script by adding a rectangle sprite that is controlled by the user’s touch. The rectangle sprite should be wider than it is tall and should initially be located at the bottom-center of the screen. The sprite’s y position should never change from its initial value. The sprite’s x position, however, should be set to the x coordinate of the user’s touch.
Modify the script to make the rectangle sprite and the bouncing sprite interact. Use the
sprite→overlaps with
function inside theadd on every frame
inline-function to test if the two sprites are overlapping. Note, do not use thesprite→overlap with
function. When the two sprites are overlapping, change the bouncing sprite’s speed as if it hit the bottom of the screen.Modify the script so that if the ball reaches the bottom of the screen, the game is over. Use the
game→end
function to end the game.
Submission
Please show your source code and run your scripts for the instructor or lab assistant.