简体   繁体   English

pygame保持得分错误

[英]pygame Error in keeping score

I'm making a platform game for class and I used this video as my guide. 我正在为课堂制作平台游戏,并以该视频为指导。 However, I'm having trouble keeping score. 但是,我无法保持得分。 Here is my code . 这是我的代码 The problem is that once I hit a coin, instead of adding only 1 point, it increments continuously. 问题是,一旦我击中硬币,而不是仅增加1点,它就会连续增加。 Please help! 请帮忙!

In this section where you check to add to the score: 在此部分中,您可以检查是否添加分数:

if self.isRight == True:
    self.score += 1

You forgot to set self.isRight back to False. 您忘记将self.isRight设置回False。 Change your code to this: 将代码更改为此:

if self.isRight == True:
    self.score +=1
    self.isRight = False

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM