Collision in 2D-Game

Hi! I thought this was an interesting challenge so I made a simple demo program.
ONLY WATCH IF YOU DON’T WANT TO FIND THE SOLUTION YOURSELF!!!

I posted it in my project library; here is the link to the “solution”