def loop(self): while True: self.window.fill((200, 200, 200)) dt = float(self.clock.get_time()) / float(config.FRAMERATE) for event in pygame.event.get(): if event.type == QUIT: pygame.quit() sys.exit() elif event.type == KEYDOWN: if event.key == K_ESCAPE or event.key == K_RETURN: enterGame(self) elif event.type == MOUSEBUTTONDOWN: for button in self.buttons: if button.hovering: button.onclick(self) for data in self.rockets: img, pos = data[0], data[1] pos[1] -= 40 * dt if (pos[1] + img.get_height()) < 0: pos[1] = self.window.get_height() + img.get_height() self.window.blit(img, pos) for button in self.buttons: button.draw(self.window) self.window.blit(self.title, (self.window.get_width() / 2 - self.title.get_width() / 2, self.window.get_height() / 4 - self.title.get_height() / 2)) pygame.display.update() self.clock.tick(config.FRAMERATE)
def draw(self, screen): self.draw_basic_elements(screen) for button in self.buttons: button.draw(screen) self.cursor.draw(screen)
def draw_basic_elements(self, screen): screen.blit(self.background, (0, 0)) screen.blit(self.title, self.title_rect) for image in self.images: screen.blit(image[1], image[2]) for button in self.buttons: button.draw(screen)
def draw(self, screen): self.draw_basic_elements(screen) for button in self.buttons: button.draw(screen) for element in self.text_layers[self.actual_layer]: screen.blit(element[0], element[1]) for element in self.elements_layers[self.actual_layer]: element.draw(screen) self.cursor.draw(screen)
def on_draw(self): arcade.start_render() arcade.draw_texture_rectangle(SCREEN_WIDTH // 2 , SCREEN_HEIGHT // 2, SCREEN_WIDTH, SCREEN_HEIGHT, self.background) for button in self.button_list: button.draw() for ball in self.ball_list: ball.draw() output = "Balls: {}".format(len(self.ball_list)) coordinate_x = "X: {}".format(self.mouse_x) coordinate_y = "Y: {}".format(self.mouse_y) arcade.draw_text(coordinate_x, 10, 50, arcade.color.WHITE, 14) arcade.draw_text(coordinate_y, 10, 70, arcade.color.WHITE, 14) arcade.draw_text(output, 10, 20, arcade.color.WHITE, 14)
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()
def draw(self, screen): ''' @brief Método que dibuja todo los componentes del menú en pantalla. Solo dibuja los elementos de la capa actual @param screen Supeficie destino ''' #Dibujamos los elementos basicos del juego self.draw_basic_elements(screen) #Dibujamos los botones de la capa actual for button in self.buttons_layers[self.actual_layer]: button.draw(screen) #Dibujamos la imagen del circuito de la imagen actual screen.blit(self.images_circuits[self.actual_layer][self.actual_circuit], self.circuit_position) screen.blit(self.actual_name, self.rect_name) #Dibujamos los tiempos del circuito actual self.times.draw(screen) #Por ultimo dibujamos el cursor self.cursor.draw(screen)
def on_draw(self): self.background.blit(0, 0) for button in self.buttons: button.draw()
def draw(self): for button in self.buttons: button.draw() self.texts.draw() self.accents.draw()
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: drink_timer.update(time_passed/10)
def draw_menu(self): """ draw the menu on the screen """ for button in self.buttons: button.draw()