# Collision Detection

## Objective

To learn about collision detection in a graphics program.

## Task

Many graphical programs such as games need some form of *collision detection*.
Not only do we want to move objects around the screen, but we also want to detect when
objects touch each other in some ways.

Game objects can have complex shapes, but collisions are usually checked against
simpler enclosing shapes. For example, a *bounding* box or bounding circle can
be used to simplify the question of whether two sprites have collided on the screen.

This lab asks you to write a Java function for testing whether two circles have collided.
That is, whether they are currently intersecting in 2D space. The program below creates 20
balls with are moving in space.

There is a "stub" method which should check whether one ball has collided with another.
Right now the function just returns false. Your job is to finish this function.

## Details

- Download the Collisions.java file.
- When you run the program, 20 random balls will move around the window.
- Write the collides function so that it returns true when two balls collide.
To do this, use the x and y locations of the two balls, along with the distance formula:

$d = \sqrt{(x_2 - x_1)^2 + (y_2 - y_1)^2}$

- When done, the balls should bounce off of each other instead of passing over
each other.

## Submitting

When your program works, email the code to ifinlay@umw.edu.
Copyright ©
2022
Ian Finlayson | Licensed under a Creative Commons Attribution 4.0 International License.