diff --git a/snake-example.py b/snake-example.py new file mode 100644 index 0000000..1b56eaf --- /dev/null +++ b/snake-example.py @@ -0,0 +1,26 @@ +# Disclaimer: this code is not complete, it is just an example + +class Snake: + def __init__(self): + self.segments = [] + self.last_direction = "UP" + self.current_head = (10, 10) + self.size = 3 + + def move(direction = None): + if direction is None: direction = self.last_direction + if self.current_head == food.location: + food.eat() + self.size += 1 + # Draw the new segment, remove the old segment, + # change self.segments as required + self.last_direction = direction + +class Food: + def __init__(self): + self.location = (5, 5) + + def eat(): + # change location, remove drawing, draw new + # location on the board + pass