Refactored game using js objects.