Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sys
- class Utilities():
- def __init__(self):
- pass
- def get_arrow_win(self):
- import msvcrt
- buttonPress = ""
- while True:
- if msvcrt.kbhit():
- buttonPress = msvcrt.getch()
- if buttonPress in arrowDictWin:
- print(arrowDictWin.get(buttonPress))
- def get_arrow_lin(self):
- import tty, termios
- buttonPress = 0
- orig_settings = termios.tcgetattr(sys.stdin)
- tty.setcbreak(sys.stdin)
- while buttonPress != chr(27):
- buttonPress = sys.stdin.read(1)[0]
- if buttonPress.lower() in arrowDictLin:
- print(arrowDictLin.get(buttonPress.lower()))
- termios.tcsetattr(sys.stdin, termios.TCSADRAIN, orig_settings)
- def clearTile(self):
- maze[playerPosRow][playerPosColumn] = " "
- def screen_clear(self):
- if name == 'nt':
- _ = system('cls')
- else:
- _ = system('clear')
- arrowDictWin = {b'w': 'UP', b'a': 'LEFT', b's': 'DOWN', b'd': 'RIGHT'}
- arrowDictLin = {'w': 'UP', 'a': 'LEFT', 's': 'DOWN', 'd': 'RIGHT'}
- obj = Utilities()
- if sys.platform == 'win32':
- obj.get_arrow_win()
- else:
- obj.get_arrow_lin()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement