Adapted from http://robots.thoughtbot.com/pong-clone-in-javascript