-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
82 lines (61 loc) · 1.5 KB
/
main.py
File metadata and controls
82 lines (61 loc) · 1.5 KB
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
import os
from getch import getch
import cursor
def clear():
os.system('clear')
map = [
['b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b'],
['b', 'p', 'p', 'p', 'p', 'p', 'p', 'p', 'p', 'b'],
['b', 'p', 'p', 'p', 'p', 'p', 'p', 'p', 'p', 'b'],
['b', 'p', 'p', 'p', 'p', 'p', 'p', 'p', 'p', 'b'],
['b', 'p', 'p', 'p', 'p', 'p', 'p', 'p', 'p', 'b'],
['b', 'p', 'p', 'p', 'd', 'p', 'p', 'p', 'p', 'b'],
['b', 'p', 'p', 'p', 'p', 'p', 'p', 'p', 'p', 'b'],
['b', 'p', 'p', 'p', 'p', 'p', 'p', 'p', 'p', 'b'],
['b', 'p', 'p', 'p', 'p', 'p', 'p', 'p', 'e', 'b'],
['b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b'],
]
def print_map():
global i
for x in map:
out = ''
for i in x:
if i == 'p':
out += ' '
elif i == 'b':
out += '░'
elif i == 'u':
out += '█'
elif i == 'd':
out += 'o'
elif i == 'e':
out +='■'
print(out)
cursor.hide()
y = 1
x = 1
while True:
os.system('clear')
map[y][x] = 'u'
print_map()
try:
map[y][x] = 'p'
keyPressed = getch()
if keyPressed == 's'and map[y+1][x] != 'b':
y += 1
elif keyPressed == 'w'and map[y-1][x] != 'b':
y -= 1
elif keyPressed == 'd'and map[y][x+1] != 'b':
x += 1
elif keyPressed == 'a'and map[y][x-1] != 'b':
x -= 1
if map[y][x] == 'd':
clear()
print("You lost...")
break
if map[y][x] == 'e':
os.system('clear')
print("Victory is yours...")
break
except:
pass