def handle_play(self): self.screen.fill((0, 0, 0)) # Wypisanie wyniku i czasu font = pygame.font.Font(None, 36) text = font.render(f"Wynik: {self.score_manager.score}", True, (255, 255, 255)) self.screen.blit(text, (10, 10)) font_time = pygame.font.Font(None, 36) text_time = font_time.render(f"Czas: {self.game_time:.2f}", True, (255, 255, 255)) self.screen.blit(text_time, (650, 10)) # Odliczanie czasu self.game_time -= 1 / 60 if self.game_time <= 0: self.game_state = GameState.GAME_OVER for event in pygame.event.get(): if event.type == pygame.QUIT: self.running = False mouse_buttons = pygame.mouse.get_pressed() is_clicked = mouse_buttons[0] # Rysowanie miecza self.sword.update() self.sword.draw(self.screen, is_clicked) # Generacja owoców od 1 do 3 sekund current_time = pygame.time.get_ticks() if current_time - self.last_fruit_time > random.randint(1000, 3000): self.sliceables.append(Sliceable()) self.last_fruit_time = current_time slashed_bomb = False for sliceable in self.sliceables: slashed_bomb = sliceable.check_collision(self.score_manager, is_clicked) sliceable.update() sliceable.draw(self.screen) # Usunięcie obiektów które spadają poza planszę if sliceable.is_off_screen(self.screen.get_height()): self.sliceables.remove(sliceable) if slashed_bomb: self.game_state = GameState.GAME_OVER