def update(self, screen): screen.fill(colors.BLACK) for button in self.key_buttons: button.update(screen) self.menu_button.update(screen) for i in self.text: screen.blit(*i)
def update(self): ''' @brief Método que actualiza lógicamente el menú Solo actualiza los elementos de la capa actual ''' self.actual_option = None #Actualizamos cada uno de los botones, por defecto del menú for button in self.buttons: button.update() #Si el cursor está sobre alguno de los botones if button.get_selected(): #Obtenemos su opción self.actual_option = button.get_option() #Actualizamos los botones de las capas for button in self.buttons_layers[self.actual_layer]: button.update() if button.get_selected(): self.actual_option = button.get_option() #Si hay algun botón seleccionado if self.actual_option: #Cambiamos el cursor self.cursor.over() #Si no, lo dejamos normal else: self.cursor.normal() #Actualizamos el cursor self.cursor.update()
def buzz_till_button(): """ Buzz until until a button press. """ while not button.pressed(): button.update() for _ in range(2): for ii in range(0, 65535, 64): analog_out.value = ii
def update(self, mouseState): # Starts the main update loop # Buttons for changing scale for button in self.buttonList: button.update(mouseState) # Test if items have been added to data and update min/max accordingly if self.oldLength < len(self.data): for i in self.data[self.oldLength:]: if i>self.maxValue: self.maxValue = i elif i<self.minValue: self.minValue = i
def update(self): self.actual_option = None for button in self.buttons: button.update() if button.get_selected(): self.actual_option = button.get_option() if self.actual_option: self.cursor.over() else: self.cursor.normal() self.cursor.update() if pygame.mouse.get_pressed()[0]: self.treat_option()
def update(self): # Starts the main update loop dt = self.clock.tick(60)/1000 for event in pygame.event.get(): if event.type == pygame.QUIT: sys.exit() if event.type == pygame.MOUSEBUTTONUP: self.mouseState[1] = True if event.type == pygame.KEYDOWN: if event.key == pygame.K_q: self.trainSum(1) elif event.key == pygame.K_w: self.trainSum(10) elif event.key == pygame.K_e: print(self.nn) elif event.key == pygame.K_z: x= self.nn.getOutput(self.imageItem[0]) print(sum(x), x) elif event.key == pygame.K_x: e = self.nn.train([self.imageItem]) self.errorList.append(e[0]) self.mouseState[0] = pygame.mouse.get_pos() log.logs = [] log.log(round(self.clock.get_fps(), 2)) log.log(self.mouseState[1]) log.log("Mode: " + self.mode.mode) self.mode.update(self.mouseState) # Update main buttons for button in self.buttonList: button.update(self.mouseState) # Update mode buttons for button in self.mode.buttonList: button.update(self.mouseState) # Mouse clicked is only true for one frame self.mouseState[1] = False
def update(self): self.actual_option = None number = 0 for button in self.buttons: button.update() number += 1 if button.get_selected(): self.actual_option = button.get_option() if self.actual_option: self.cursor.over() else: self.cursor.normal() for element in self.elements_layers[self.actual_layer]: element.update() self.cursor.update() if pygame.mouse.get_pressed()[0]: self.treat_option()
def run(self): ''' Función que contiene el bucle principal del juego. Actualiza y dibuja el estado actual. ''' while not keyboard.quit(): self.clock.tick(self.fps) keyboard.update() for button in self.buttons: button.update() if button.get_selected() and pygame.mouse.get_pressed()[0]: self.treat_option(button.get_option()) self.timer.update() self.timer2.update() self.timer3.update() self.screen.fill(THECOLORS['white']) for button in self.buttons: button.draw(self.screen) self.timer.draw(self.screen) self.timer2.draw(self.screen) self.timer3.draw(self.screen) #self.__actual_state.update() #self.__actual_state.draw(screen) if self.__start and time.time() - self.__start >= 5: self.__start = time.time() if self.timer2.less_than(self.timer): self.timer2.assign(self.timer) elif self.timer2.more_than(self.timer): print "Es mayoooor" pygame.display.flip()
o_varb = 0.1 o_brit = 0.3 o_hue = random.random() o_step = 0.01 # Adjustable timer step (s) timer_step = 5 # Initalize timer timer_limit = 0 timer_start = time.monotonic() mode = "ambient" while True: # Check for user interaction button.update() if button.just_pressed(): mode = "timer" clicks = 0 update_console(clicks, 1) t0 = time.monotonic() while time.monotonic() - t0 < 1: button.update() if button.just_pressed(): clicks += 1 update_console(clicks, 1) # Allow another second to press the button again t0 = time.monotonic() time.sleep(0.01)
elif key[pygame.K_n]: pygame.event.post(pygame.event.Event(USEREVENT, num=5)) elif key[pygame.K_t]: pygame.event.post(pygame.event.Event(USEREVENT+11)) else: dispatcher.dispatch(event) time_passed = clock.tick(20) # limit to x FPS time_passed_seconds = time_passed / 1000.0 # convert to seconds timer_next_card(time_passed_seconds) ##print clock.get_fps() screen.blit(background, (0,0)) card_deck.draw(screen) timer_button.update(time_passed_seconds) timer_button.draw(950,150,screen) button.update(time_passed_seconds) button.draw(68, 105,screen) button2.update(time_passed_seconds) button2.draw(305,562,screen) button3.update(time_passed_seconds) button3.draw(1073, 273,screen) tangera_handler.draw(screen) player_handler.update(time_passed_seconds) player_handler.draw(screen) rule_handler.update(time_passed_seconds) rule_handler.draw(screen) ## Drink timer if timer_on: