1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
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)
|