Home CPSC 220

Collision Detection



To learn about collision detection in a graphics program.


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.





When your program works, email the code to ifinlay@umw.edu.

Copyright © 2022 Ian Finlayson | Licensed under a Attribution-NonCommercial 4.0 International License.