我有我的遊戲的一個問題是在這裏,我認爲是造成問題Python的遊戲不工作
def move(self):
self.canvas.move(self.Oball,self.move_x,0)
if self.canvas.coords(self.Oball)[0] <= 0:
self.move_x = 1
elif self.canvas.coords(self.Oball)[2] >= 700:
self.move_x = -1
def EatBall(self):
if self.canvas.coords(self.ball) == self.canvas.coords(ball1.Oball):
canvas.delete(ball1.Oball)
self.PlayerWon += 1
elif self.canvas.coords(self.ball) == self.canvas.coords(ball2.Oball):
canvas.delete(ball2.Oball)
self.PlayerWon += 1
elif self.canvas.coords(self.ball) == self.canvas.coords(ball3.Oball):
canvas.delete(ball3.Oball)
self.PlayerWon += 1
if self.PlayerWon == 3:
time2 = time()
TimeItTook = time2 - self.time1
canvas.create_text(350,100,text="You Won",font=("Arial",22))
canvas.create_text(350,200,text="It took you %s seconds to eat all the balls" % int(TimeItTook),font=("Arial",18))
self.PlayerWon = 10
行「的功能,如果self.canvas.coords(self.Oball)[0] < = 0:「正在返回一個錯誤,並導致遊戲崩潰。 另外我在Eatball功能中遇到問題。 在函數中,變量self.PlayerWon在每次吃球時都不會增加。 我在編碼所以小白代碼可能是混亂 請幫我解決這個問題
請閱讀http://stackoverflow.com/help/mcve - 絕對沒有理由說任何問題都應該開始,「我正在寫一個[大型項目],下面是整個代碼庫。」 –