bevor ich aber nun alle figuren nach einen bestimmten muster schrebe und feststellen kann das dieser anderes sein solte frage ich euch lieber was ihr davon hält:
Code: Alles auswählen
class Dre():
def __init__(self, x, y):
self.x = x
self.y = y
self.figur = None
self.position = 1
def down(self):
self.y -=1
def right(self):
self.x +=1
def left(self):
self.x -= 1
def turn(self):
if self.position == 4:
self.position = 1
else:
self.position = self.position + 1
def get(self):
#self.figur = self._form()
self.figurAlt = self.figur
if self.position == 1:
self.figur = [
[self.x,self.y+1],
[self.x-1,self.y], [self.x,self.y], [self.x+1,self.y],
]
elif self.position == 2:
self.figur = [
[self.x,self.y+1],
[self.x,self.y], [self.x+1,self.y],
[self.x,self.y-1],
]
elif self.position == 3:
self.figur = [
[self.x-1,self.y], [self.x,self.y], [self.x+1,self.y],
[self.x,self.y-1]
]
elif self.position == 4:
self.figur = [
[self.x,self.y+1],
[self.x-1,self.y], [self.x,self.y],
[self.x,self.y-1]
]
return {"new": self.figur, "old": self.figurAlt}
Code: Alles auswählen
def show(fieldObj, figurObj, char):
z = figurObj.get()
if z["old"]:
for i in z["old"]:
fieldObj.set(i[0], i[1], " ")
for i in z["new"]:
fieldObj.set(i[0], i[1], char)
fieldObj.show()
danke