Changed game loop to use requestanimationframe