From bc09da5a7b65b08b5d5dcd1e90173ad3b6081c23 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Mon, 29 Jul 2019 11:46:36 +0300 Subject: Did some more work in Python and started officially learning Java --- Python/Beginner training/Game test.py | 41 +++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 Python/Beginner training/Game test.py (limited to 'Python/Beginner training/Game test.py') diff --git a/Python/Beginner training/Game test.py b/Python/Beginner training/Game test.py new file mode 100644 index 0000000..dd35499 --- /dev/null +++ b/Python/Beginner training/Game test.py @@ -0,0 +1,41 @@ +import sys +import math +import random +import os +import keyboard +import time + +ORIGINAL_MAP = [[' ', '>', '-', '-', '-', '-', ' '], + [' ', '|', ' ', ' ', ' ', '|', ' '], + [' ', '[', ' ', ' ', ' ', '|', ' '], + [' ', '-', '-', '-', '=', '-', ' ']] +map = ORIGINAL_MAP[:] + +player = '*' +xPos = 1; yPos = 0 + +def ReWriteScreen(): + map = ORIGINAL_MAP[:] + + for i in range(len(ORIGINAL_MAP)): + for j in range(len(ORIGINAL_MAP[0])): + if i == yPos: map[yPos][xPos] = player + + print(end=map[i][j]) + print() + +while True: + try: + if keyboard.is_pressed('w') and yPos > 0: + yPos -= 1 + elif keyboard.is_pressed('s') and yPos < 3: + yPos += 1 + elif keyboard.is_pressed('a') and xPos > 1: + xPos -= 1 + elif keyboard.is_pressed('d') and xPos < 5: + xPos += 1 + except: + continue + + ReWriteScreen() + time.sleep(1) \ No newline at end of file -- cgit v1.2.3