pythonpygamesprite2d-gamestmx

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. Please help!


Solution

  • 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. Change your code to this:

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