Extract a drawSnake function