Python/snake.py
def move_food():
    "Move food one step in a random direction"
    direction = randrange(1, 4)
    if direction == 1:
        food.x = food.x - 10
        if not inside(food):
            food.x = food.x + 10
    elif direction == 2:
        food.x = food.x + 10
        if not inside(food):
            food.x = food.x - 10
    elif direction == 3:
        food.y = food.y - 10
        if not inside(food):
            food.y = food.y + 10
    elif direction == 4:
        food.y = food.y + 10
        if not inside(food):
            food.y = food.y - 10
    ontimer(move_food, 2000)
Move food one step in a random direction
Move food one step in a random direction
Move food one step in a random direction
def move_food():
    direction = randrange(1, 4)
    if direction == 1:
        food.x = food.x - 10
        if not inside(food):
            food.x = food.x + 10
    elif direction == 2:
        food.x = food.x + 10
        if not inside(food):
            food.x = food.x - 10
    elif direction == 3:
        food.y = food.y - 10
        if not inside(food):
            food.y = food.y + 10
    elif direction == 4:
        food.y = food.y + 10
        if not inside(food):
            food.y = food.y - 10
    ontimer(move_food, 2000)
def move_food ( ) : direction = randrange ( 1 , 4 ) if direction == 1 : food . x = food . x - 10 if not inside ( food ) : food . x = food . x + 10 elif direction == 2 : food . x = food . x + 10 if not inside ( food ) : food . x = food . x - 10 elif direction == 3 : food . y = food . y - 10 if not inside ( food ) : food . y = food . y + 10 elif direction == 4 : food . y = food . y + 10 if not inside ( food ) : food . y = food . y - 10 ontimer ( move_food , 2000 )
Move food one step in a random direction
Move food one step in a random direction
"Move food one step in a random direction"