Advertisement
DrAungWinHtut

adventure2.py

Mar 25th, 2023
746
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.96 KB | None | 0 0
  1. gx = 58
  2. gy = 10
  3.  
  4. ux = 2
  5. uy = 2
  6.  
  7. key = 'start'
  8.  
  9. print('Game is Starting...')
  10. print('Use A,D,W,S kyes to move...')
  11. print('You are in the middle of no where now!!! x = {} and y= {}'.format(ux, uy))
  12.  
  13. while key != 'q':
  14.     key = input()
  15.     if key.lower() == 'a':
  16.         print('you move to left....')
  17.         ux = ux - 1
  18.         if ux < 0:
  19.             ux = 0
  20.     elif key.lower() == 'd':
  21.         print('you move to right....')
  22.         ux = ux + 1
  23.         if ux > 100:
  24.             ux = 100
  25.     elif key.lower() == 'w':
  26.         print('you move to up....')
  27.         uy = uy - 1
  28.         if uy < 0:
  29.             uy = 0
  30.     elif key.lower() == 's':
  31.         print('you move to down....')
  32.         uy = uy + 1
  33.         if uy > 100:
  34.             uy = 100
  35.  
  36.     print('Your current location is now at x = {} and y= {}'.format(ux, uy))
  37.  
  38.     if (ux == gx) and (uy == gy):
  39.         print('You found the gold bag!!!')
  40.         print()
  41.         print()
  42.         exit()
  43.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement