engine umschmweißen
This commit is contained in:
parent
bc660afdbc
commit
d83e2f7232
5 changed files with 97 additions and 108 deletions
Binary file not shown.
|
@ -2,51 +2,52 @@
|
|||
from os import get_terminal_size
|
||||
tx,ty = get_terminal_size().columns ,get_terminal_size().lines-2
|
||||
|
||||
def genfeld():
|
||||
return [[' ' for _ in range(tx)] for _ in range(ty+2)]
|
||||
class tengine():
|
||||
def __init__(self) -> None:
|
||||
self.screen = [[' ' for _ in range(tx)] for _ in range(ty+2)]
|
||||
|
||||
def bg_char(feld, char=' '):
|
||||
for a in range(len(feld)):
|
||||
for b in range(len(feld[0])):
|
||||
feld[a][b] = char
|
||||
return feld
|
||||
def print(self):
|
||||
print(self.strscreen(),end="\r")
|
||||
|
||||
def strfeld(feld):
|
||||
return '\n'.join([''.join(row) for row in feld]).lstrip('\n').rstrip('\n')
|
||||
def prfeld(feld):
|
||||
print(strfeld(feld),end="\r")
|
||||
def bg_char(self, char=' '):
|
||||
self.prfeld()
|
||||
for a in range(len(self.screen)):
|
||||
for b in range(len(self.screen[0])):
|
||||
self.screen[a][b] = char
|
||||
|
||||
|
||||
def strscreen(self):
|
||||
back = ""
|
||||
for a in self.screen:
|
||||
line = ""
|
||||
for b in a:
|
||||
line += str(b)
|
||||
back += line[:tx] + "\n"
|
||||
return back.lstrip('\n').rstrip('\n')
|
||||
|
||||
|
||||
def change_char(feld, character, position):
|
||||
feld[position[0]][position[1]] = character
|
||||
def set_char(self, character, position):
|
||||
self.screen[position[0]][position[1]] = character
|
||||
|
||||
def set_block(self, block, position):
|
||||
position = [position[0]+1,position[1]]
|
||||
pposition = position
|
||||
for zeichen in block:
|
||||
if zeichen == '\n':
|
||||
pposition = [pposition[0] + 1, position[1]]
|
||||
else:
|
||||
pposition = [pposition[0], pposition[1] + 1]
|
||||
self.screen[pposition[0]][pposition[1]] = zeichen
|
||||
|
||||
def change_block(feld, block, position):
|
||||
position = [position[0]+1,position[1]]
|
||||
pposition = position
|
||||
for zeichen in block:
|
||||
if zeichen == '\n':
|
||||
pposition = [pposition[0] + 1, position[1]]
|
||||
else:
|
||||
pposition = [pposition[0], pposition[1] + 1]
|
||||
feld[pposition[0]][pposition[1]] = zeichen
|
||||
return feld
|
||||
def clear(self):
|
||||
print('\033c', end='')
|
||||
|
||||
def clear():
|
||||
print('\033c', end='')
|
||||
|
||||
def draw_border(feld, border_char='+'):
|
||||
for i in range(len(feld)):
|
||||
feld[i][0] = feld[i][-1] = border_char
|
||||
for j in range(len(feld[0])):
|
||||
feld[0][j] = feld[-1][j] = border_char
|
||||
global tx,ty
|
||||
tx -= 2;ty -= 2
|
||||
return feld
|
||||
|
||||
#def move_cursor(x, y):
|
||||
# print(f'\033[{y};{x}H', end='')
|
||||
|
||||
def viereck(feld, start_pos, width, height, fill_char='#'):
|
||||
for i in range(height):
|
||||
for j in range(width):
|
||||
feld[start_pos[0]+1 + i][start_pos[1] + j] = fill_char
|
||||
return feld
|
||||
def draw_border(self, border_char='+'):
|
||||
for i in range(len(self.screen)):
|
||||
self.screen[i][0] = self.screen[i][-1] = border_char
|
||||
for j in range(len(self.screen[0])):
|
||||
self.screen[0][j] = self.screen[-1][j] = border_char
|
||||
def viereck(self, start_pos, width, height, fill_char='#'):
|
||||
for i in range(height):
|
||||
for j in range(width):
|
||||
self.screen[start_pos[0]+1 + i][start_pos[1] + j] = fill_char
|
Loading…
Add table
Add a link
Reference in a new issue