O
O
oledjigames2020-11-05 00:02:03
Python
oledjigames, 2020-11-05 00:02:03

Python str in a class doesn't change, what's wrong?

When self.choice_var = ('yes') or ('no') happens but choice_1 doesn't change to ('yes') or ('no') but remains the original choice_1 = yes why?
The code:

choice_1 = 'yes'
class choice:
    def __init__(self,level_num, text1, text2, choice_var, background, player, player_x, player1, player1_x):
         self.level_num = level_num
         self.text1 = text1
         self.text2 = text2
         self.choice_var = choice_var
         self.background = background
         self.player = player
         self.player_x = player_x
         self.player1 = player1
         self.player1_x = player1_x
         self.show()
    def show(self):
        if level_selected==(self.level_num):
            screen.blit(self.background,(0, 0))
            screen.blit(self.player, (self.player_x, 0))
            screen.blit(self.player1, (self.player1_x, 0))
            screen.blit(choice_pic,(0, 0))
            if mousey<=(295):
                text_choice_1 = font1.render(self.text1, 1, YELLOW)
                text_choice_2 = font1.render(self.text2, 1, WHITE)
                self.choice_var = ('yes')
            elif mousey>=(295):
                text_choice_2 = font1.render(self.text2, 1, YELLOW)
                text_choice_1 = font1.render(self.text1, 1, WHITE)
                self.choice_var = ('no')
            screen.blit(text_choice_1,(452, 233))
            screen.blit(text_choice_2,(452, 320))
            pygame.display.update()
        pass

in a loop:
dialog1 = choice(9, "yesyesyesyesyesyesyes", "no", choice_1, background2, player0, 120, player1, -120)
    dialog1.show()

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question