start of snake movement

This commit is contained in:
2022-07-31 19:48:16 +02:00
parent 7105b7ef27
commit c74dfcc1a3
2 changed files with 20 additions and 3 deletions

View File

@ -1,4 +1,6 @@
DIRECTION = {'left': (0, -1), 'right': (0, 1), 'up': (-1, 0), 'down': (1, 0)}
class List:
def __init__(self, val, next):
self.val = val
@ -26,3 +28,16 @@ class List:
L = L.next
return i
def Snake_move(M, L, dir):
L_save = L
L.val = (DIRECTION[dir][0] + L.val[0], DIRECTION[dir][1] + L.val[1])
L = L.next
L_save = L_save.next
while L is not None:
L = L.next