def updatedcollisions(self):
self.xcord, self.ycord = pygame.mouse.get_pos()
if self.confirmationscreen == True:
if self.xcord < 150 or self.xcord > 650 and self.ycord < 200 or self.ycord > 700:
print('Out of Screen')
self.confirmationscreen = False
pygame.Surface.fill(self.win,('black'))
self.loadonce()
self.buttons()
self.font = pygame.font.Font(r'D:\Games\First Game\FreeSans\FreeSansBold.ttf',28)
self.text = self.font.render(f'Multiplier {self.moneyperclick}', True, (255,255,255))
self.textRect = self.text.get_rect()
self.textRect.center = (self.width//2, 150)
pygame.draw.rect(self.win,(0,0,0),self.textRect)
self.win.blit(self.text, self.textRect)
else:
if 300 <= self.xcord <= 400 and 600 <= self.ycord <= 700:
self.win.blit(self.whiteboard,[(self.width/2)-150,(self.height/2)-200])
self.multiplier()
self.confirmation()
elif 150 <=self.xcord <= 250 and 600 <= self.ycord <=700:
print('Worked')
self.money = self.money - self.moneyperclick
pygame.display.update()
else:
self.whiteboardfiller()
self.updatedcollisions()
self.moneytracker()
self.money = round(self.money,2)
self.changingtextstuff(f'Whiteboards {self.money}')
我做了一些研究,發現這意味著它正在回圈執行某些操作,但我不明白為什么它無法處理它。錯誤資訊也說if type(random) is BuiltInMethod or type(getrandbits) is Method:。如果有人可以提供幫助,那就太棒了。完整代碼在這里。
uj5u.com熱心網友回復:
超過最大遞回深度意味著您的代碼呼叫自身的次數過多,解釋器無法處理。在這種情況下,我相信罪魁禍首是self.updatedcollisions()你的第二個 else 陳述句。
假設您updatedcollisions()在代碼中呼叫了。如果confirmationscreen為假,則跳轉到第一個 else 塊。在那個 else 塊中,如果這個物件不在正確的邊界內(if 和 elif 陳述句都是假的),代碼會跳轉到最后的 else 塊。在最后一個 else 塊中,updatedcollisions()再次被呼叫,回圈一遍又一遍地重復,直到遞回太深而無法處理,從而導致程式崩潰。
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/337433.html
下一篇:(functree)元素的總和
