samedi 20 février 2021

If statment has invalid syntax

Im am currently trying to make a game within pygame and am in the process of adding some music, the current code I have is this

    if self.room.running = True:
        self.music_sound = self.load_sound('Song.mp3')
        self.music_sound.play()
    else:
        self.music_sound.stop()

The idea is that when executed, the song would play until the room was no longer running and the player had moved onto the next level.

however, when I try to run the code, it comes up with this error

  if self.room.running = True:     
                       ^
  SyntaxError: invalid syntax

Any help would be appreciated :)

Aucun commentaire:

Enregistrer un commentaire