Ich versuche, ein Minenspiel zu erstellen, aber es stürzt jedes Mal ab. Kannst du mir helfen? Hier ist mein Code:Python 3.x - Python Tkinter
def refill(event):
for i in everything:
c.delete(i) # This is the 'Delete' statement
time.sleep(0.01)
global x2
global y2
for i in range(10): # This is the 'Create' statement
for i in range(10):
if random.randint(1, IRON_CHANCE) != 1:
stone = c.create_rectangle(x2, y2, x2 + 50, y2 + 50, fill='dim gray')
everything.append(stone)
y2 += 50
if random.randint(1, IRON_CHANCE) == 1:
ironStone = c.create_rectangle(x2, y2, x2 + 50, y2 + 50, fill='dim gray')
ironRect = c.create_rectangle(x2 + 10, y2 + 10, x2 + 40, y2 + 40, fill='ivory')
irons.append(ironRect)
everything.append(ironStone)
everything.append(ironRect)
y2 += 50
time.sleep(0.01)
x2 += 50
y2 = 0
time.sleep(0.01)
Ich denke, das Problem liegt im 'Create' Zustand. Wenn ich diesen Zustand lösche, funktioniert das Spiel glatt und fein. Kannst du mir bitte helfen?
Können Sie bitte ein [minimales, vollständiges und überprüfbares Beispiel] (https://stackoverflow.com/help/mcve) erstellen, das Ihr Problem reproduziert? –
Ist das Ihr ganzer Code? Wenn nicht, fügen Sie bitte einen Kontext hinzu. –
immer volle Fehlermeldung (Traceback) in Frage stellen (als Text, nicht als Screenshot). Es gibt andere nützliche Informationen. Und wir können nicht in deinem Verstand lesen noch sehen Sie Ihren Bildschirm (magische Glaskugel kaputt) – furas