engine erweitern

This commit is contained in:
Michael S. 2023-11-06 20:13:12 +01:00
parent 20d4a8f432
commit 6af5e8afc9
3 changed files with 47 additions and 31 deletions

View file

View file

@ -1,22 +1,42 @@
from os import get_terminal_size from os import get_terminal_size
class tengine(): tx = get_terminal_size().columns
tx, ty = get_terminal_size().columns, get_terminal_size().lines ty = get_terminal_size().lines
#feld = [[""]*10]*10 def genfeld():
feld = [["","","",],["","","",],["","","",]] feld = [[' ' for _ in range(tx)] for _ in range(ty)]
return feld
def bg_char(feld,char=str):
test = 0 test = 0
for a in range(len(feld)):
for b in range(len(feld[0])):
feld[a][b] = test
test = char
return feld
def strfeld(feld):
back = ""
for a in feld: for a in feld:
for b in a: for b in a:
print(test) back += str(b)
b = test back += "\n"
test +=1 return back
print(feld)
def strfeld(): def change_char(feld,character=str,position=list):
back = "" feld[position[0]][position[1]] = character
for a in tengine.feld: def change_block(feld,string=str,position=list):
for b in a: a = ""
back += b block_len = 0
back += "\n" for a in string:
return back if a == "\n":
def addchar(character=str,position=list): break
tengine.feld[2][2] = "a" else:
block_len += 1
print(block_len)
for zeichen in string:
feld[position[0]][position[1]] = zeichen
position[0] += 1
if position[0]== block_len-1:
position[0] = 0
return feld

View file

@ -1,15 +1,11 @@
#from tengine import tengine import tengine
#tengine.addchar("a",[5,5]) feld = tengine.genfeld()
#print(tengine.feld)
feld = [["","","",],["","","",],["","","",]] block = "halli\nhallo\nfurz"
feld[1][1] = "a" block2 = """halli
test = 0 hallo
for a in feld: furz"""
for b in a:
print(test) feld = tengine.bg_char(feld,"#")
b = test feld = tengine.change_block(feld,block2,[3,3])
print(b) print(tengine.strfeld(feld))
test +=1
feld[1][1] = "a"
print(feld)