-1

I am coding a simple game and I am having the next trouble:

if pidgeon.rect.y > 360:

    pygame.mixer.music.stop()
    pidgeon.electrocute()
    electrocute.play()
    time.sleep(2)
    showGameOverScreen(score, total_score)

The method that is not working is:

pidgeon.electrocute()

Which should do the next:

def electrocute(self):
    self.image=pygame.image.load(r"electrocuted_pidgeon.png").convert() 
    self.image.set_colorkey((255,255,255))  

But instead of changing the pidgeon image, while playing the electrocute sound. It just waits the 2 seconds, while playing the electrocute sound and then it goes to the gameover screen. Why is it not changing the image?

I've tried in other parts of the code (e.g. when pressing bar space it should change, and it does), so the image can change.

I am using pygame in python 2.7, just in case.

1 Answers1

0

try to call it like this. this is a small example based on user input value.

class fly:
    def mymethod(self):
        print("canada")

def testmethod():
    print("this should be greater")

for i in range(0,3):
    userInput = int(input("Enter any number :"))

    if(userInput > 5):
        print("greater")

    else:
        testmethod()
        s = fly()
        s.mymethod()
caldera.sac
  • 4,918
  • 7
  • 37
  • 69