Advertisement
AarellanoH

Untitled

Feb 27th, 2016
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.42 KB | None | 0 0
  1. class Simon_Says:
  2.     matrix = Matrix()
  3.     buttons = Button_Array()
  4.  
  5.     def __init__(self, maximum_rounds):
  6.         self.actual_list = []
  7.         self.answer_list = []
  8.         self.maximum_rounds = maximum_rounds
  9.         self.current_round = 0
  10.         return
  11.  
  12.     def add_element(self):
  13.         self.actual_list.append(random.randrange(4))
  14.  
  15.     def receive_list(self):
  16.         matrix.display_message("Ronda " + str(len(self.actual_list)))
  17.         for i in range(0, len(self.actual_list)):
  18.             input = buttons.get_input()
  19.             if self.actual_list[i] == input:
  20.                 matrix.display_letter(input, '*')
  21.             else:
  22.                 matrix.display_letter(input, 'x')
  23.         return True
  24.  
  25.     def show_actual_list(self):
  26.         matrix.clear_screen()
  27.         for element in self.actual_list:
  28.             matrix.display_letter(element, "*")
  29.             time.sleep(2)
  30.  
  31.  
  32.     def run(self):
  33.         aux = 0
  34.         while self.maximum_rounds >= self.current_round:
  35.             while aux < self.current_round:
  36.                 self.add_element()
  37.                 aux += 1
  38.             self.show_actual_list()
  39.             coorect = self.receive_list()
  40.             if not correct:
  41.                 print "perdiste"
  42.                 break
  43.             self.actual_list = []
  44.             aux = 0
  45.             self.current_round += 1
  46.         print "Ganaste"
  47.  
  48.  
  49.  
  50.  
  51.  
  52. simon = Simon_Says(8)
  53. simon.run()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement