Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- hx = 6
- hy = 3
- sbx1 = 1
- sby1 = 3
- stx1 = 2
- sty1 = 1
- sbx2 = 1
- sby2 = 8
- stx2 = 2
- sty2 = 6
- dbx1 = 3
- dby1 = 3
- dtx1 = 4
- dty1 = 1
- dbx2 = 5
- dby2 = 5
- dtx2 = 6
- dty2 = 1
- ux = 5
- uy = 5
- ans = 'start'
- marks = 100
- filename = 'd:\\gamedata.txt'
- log_file = open(filename, 'a')
- print("Game is Starting...")
- print("Game Control a-left,d-right,w-up,s-down,q-quit...")
- print("Your Starting Position is x={} and y={}".format(ux, uy))
- log_file.write('x={},y={}\n'.format(ux, uy))
- print()
- print()
- while ans != 'q':
- ans = input(">>>")
- marks = marks - 1
- if ans == 'a':
- ux = ux - 1
- if ux < 1:
- ux = 1
- elif ans == 'd':
- ux = ux + 1
- if ux > 10:
- ux = 10
- elif ans == 'w':
- uy = uy - 1
- if uy < 1:
- uy = 1
- elif ans == 's':
- uy = uy + 1
- if uy > 10:
- uy = 10
- print("Your Current Position is x={} and y={}".format(ux, uy))
- log_file.write(
- 'Your Current Position is x={} and y={}\n'.format(ux, uy))
- if (ux == sbx1) and (uy == sby1):
- ux = stx1
- uy = sty1
- print("Wow Stair!!!!\nYour Current Position is x={} and y={}".format(ux, uy))
- log_file.write(
- "Wow Stair!!!!\nYour Current Position is x={} and y={}\n".format(ux, uy))
- elif (ux == sbx2) and (uy == sby2):
- ux = stx2
- uy = sty2
- print("Wow Stair!!!!\nYour Current Position is x={} and y={}".format(ux, uy))
- log_file.write(
- "Wow Stair!!!!\nYour Current Position is x={} and y={}\n".format(ux, uy))
- elif (ux == dtx1) and (uy == dty1):
- ux = dbx1
- uy = dby1
- print("Ahhh Snake!!!!\nYour Current Position is x={} and y={}".format(ux, uy))
- log_file.write(
- "Ahhh Snake!!!!\nYour Current Position is x={} and y={}\n".format(ux, uy))
- elif (ux == dtx2) and (uy == dty2):
- ux = dbx2
- uy = dby2
- print("Ahhh Snake!!!!\nYour Current Position is x={} and y={}".format(ux, uy))
- log_file.write(
- "Ahhh Snake!!!!\nYour Current Position is x={} and y={}\n".format(ux, uy))
- elif (ux == hx) and (uy == hy):
- print("Finally, Home Sweet Home!!!")
- log_file.write("Finally, Home Sweet Home!!!\n")
- print("your mark is {}".format(marks))
- log_file.write("your mark is {}\n".format(marks))
- log_file.close()
- exit()
- log_file.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement