-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsnake.py
More file actions
39 lines (32 loc) · 741 Bytes
/
snake.py
File metadata and controls
39 lines (32 loc) · 741 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
wall = "X"
x = 4
y = 5
prompt = '> '
print("What map do you want to play on?")
file = input(prompt)
map = open(file, 'r+')
lines = map.readlines()
def printMap():
i = 0
for line in lines:
print(lines[i])
if(i == y):
print("X" + " " * x + "0")
i = i + 1
printMap()
while(True):
print("Which direction? N/S/E/W")
direction = input()
if(direction == 'N' or direction == 'n'):
y = y - 1
print(x, y)
if(direction == 'S' or direction == 's'):
y = y + 1
print(x, y)
if(direction == 'W' or direction == 'w'):
x = x - 3
print(x, y)
if(direction == 'E' or direction == 'e'):
x = x + 3
print(x, y)
printMap()