【发布时间】:2021-12-11 07:57:50
【问题描述】:
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:。如果有人可以提供帮助,那就太棒了。
完整代码是here。
【问题讨论】:
-
self.updatedcollisions()- 方法调用自身。在这个方法中似乎没有任何东西会改变任何变量,因此条件不会再次相同,所以它会再次调用自己,以此类推。
标签: python python-3.x recursion