aboutsummaryrefslogtreecommitdiff
path: root/Python/Beginner training/Game test.py
diff options
context:
space:
mode:
Diffstat (limited to 'Python/Beginner training/Game test.py')
-rw-r--r--Python/Beginner training/Game test.py41
1 files changed, 41 insertions, 0 deletions
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