Also never use Math.pow for squaring numbers (used in the distance function) because it is significantly slower as it is designed for abitrary real exponents, not just integer ones. Cannot be learned soon enough IMO :)
Still a very good job for just a week of coding though.