mirror of
https://github.com/d3vyce/Python-Game.git
synced 2025-04-03 12:23:22 +02:00
start of snake movement
This commit is contained in:
parent
7105b7ef27
commit
c74dfcc1a3
@ -10,17 +10,19 @@ WIDTH = 20
|
||||
|
||||
def main():
|
||||
test = snake.List((5, 5), None)
|
||||
test = snake.List.List_add(test, 12)
|
||||
test = snake.List.List_add(test, 14)
|
||||
test = snake.List.List_add(test, 16)
|
||||
test = snake.List.List_add(test, (6, 6))
|
||||
test = snake.List.List_add(test, (7, 7))
|
||||
test = snake.List.List_add(test, (8, 8))
|
||||
print(test)
|
||||
print("Size : ", snake.List.List_size(test))
|
||||
|
||||
|
||||
matrix = level.init_level(HEIGH, WIDTH)
|
||||
matrix[5][5] = 1
|
||||
level.spawn_apple(matrix, HEIGH, WIDTH)
|
||||
print(matrix)
|
||||
|
||||
snake.Snake_move(matrix, test, "left")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
@ -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
|
Loading…
x
Reference in New Issue
Block a user