forked from ripexz/dungeon-treasure-hunt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlaberinto_a_puntos.py
66 lines (63 loc) · 1.77 KB
/
laberinto_a_puntos.py
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
#!/usr/bin/env python
#-*- coding: utf-8 -*-
#import os # os.system('cls') # on windows
from random import randint,shuffle
lab = [[0 for i in range(11)]for i in range(11)]
prs = 'O' #Personaje: Letra que se escojerá para usar en el laberinto
box = [1,2,3,4]
cheese=[]
for i in range(11):
for j in range(11):
if i%2==0:
print(j,end='')
if i>4: cheese.append([i,j])
else:
if j%2==1:
print('X',end='')
lab[i][j]=1
shuffle(box)
if box[0]==1: lab[i+1][j]=1
if box[0]==2: lab[i-1][j]=1
if box[0]==3: lab[i][j+1]=1
if box[0]==4: lab[i][j-1]=1
else: print(j,end='')
print('')
print(cheese)
def mapa():
import os
os.system('cls') # on windows
for i in lab:
for j in i:
if j==0:
print(' ',end='')
elif j==2: print(prs[0],end='')
else: print('X',end='')
print()
def move():
global YR,XR,YS,XS
print('you are in ',YR,XR, ', The exit is in ',YS,XS)
key=str(input('Keys: [W]->UP [A]->LEFT [S]->DOWN [D]->RIGHT:\n')).upper()
lab[YR][XR]=0
for i in range(len(key)):
if key[i]=='W': YR-=1
if key[i]=='A': XR-=1
if key[i]=='S': YR+=1
if key[i]=='D': XR+=1
lab[YR][XR]=2
mapa()
if not((YR==YS) and (XR==XS)): move()
if __name__=='__main__':
YR=0;XR=0;
lab[YR][XR]=2
mapa()
prs = str(input('Eliga una letra o símbolo y presione enter: '))
#for i in [i for i in range(11+1)]:
# print(i)
input('Checkpoint')
YS=0;XS=0;
while (YS<5) or (XS<5):
YS=randint(0,11)
XS=randint(0,11)
input('Checkpoint')
move()
print('You Win!')