Compare commits

..

No commits in common. "4e90ecb885b604aa0b9af80cf8528debdad10853" and "d0f01c0a488f1c9f58cd3e28a30d0f190cd9436b" have entirely different histories.

3 changed files with 6 additions and 25 deletions

View File

@ -122,20 +122,8 @@ class SimulationEngine:
self._handle_sprint_mode()
return
# Only process one tick per frame if enough time has passed
if not self.input_handler.is_paused:
current_time = time.perf_counter()
if current_time - self.last_tick_time >= tick_interval:
self.last_tick_time += tick_interval
self.tick_counter += 1
self.total_ticks += 1
self.input_handler.update_selected_objects()
self.world.tick_all()
self.hud.manager.update(deltatime)
if current_time - self.last_tps_time >= 1.0:
self.actual_tps = self.tick_counter
self.tick_counter = 0
self.last_tps_time += 1.0
self._handle_simulation_ticks(tick_interval, deltatime)
else:
self.last_tick_time = time.perf_counter()
self.last_tps_time = time.perf_counter()
@ -175,11 +163,9 @@ class SimulationEngine:
self.last_tps_time = time.perf_counter()
self.screen.fill(BLACK)
self.renderer.clear_screen()
cell_count = self._count_cells()
self.hud.render_sprint_debug(self.screen, self.actual_tps, self.total_ticks, cell_count)
self.hud.render_sprint_debug(self.screen, self.actual_tps, self.total_ticks)
pygame.display.flip()
self.clock.tick(MAX_FPS)
self.last_tick_time = time.perf_counter()
def _handle_simulation_ticks(self, tick_interval, deltatime):
current_time = time.perf_counter()
@ -217,8 +203,8 @@ class SimulationEngine:
self.hud.draw_splitters(self.screen)
# self.hud.render_mouse_position(self.screen, self.camera, self.sim_view_rect)
self.hud.render_fps(self.screen, self.clock)
self.hud.render_tps(self.screen, self.actual_tps)
# self.hud.render_fps(self.screen, self.clock)
# self.hud.render_tps(self.screen, self.actual_tps)
# self.hud.render_tick_count(self.screen, self.total_ticks)
# self.hud.render_selected_objects_info(self.screen, self.input_handler.selected_objects)
self.hud.render_legend(self.screen, self.input_handler.show_legend)

View File

@ -641,20 +641,17 @@ class HUD:
screen.blit(surf, (tooltip_rect.left + TOOLTIP_PADDING_X, y))
y += surf.get_height() + TOOLTIP_LINE_SPACING
def render_sprint_debug(self, screen, actual_tps, total_ticks, cell_count=None):
def render_sprint_debug(self, screen, actual_tps, total_ticks):
"""Render sprint debug info: header, TPS, and tick count."""
header = self.font.render("Sprinting...", True, (255, 200, 0))
tps_text = self.font.render(f"TPS: {actual_tps}", True, (255, 255, 255))
ticks_text = self.font.render(f"Ticks: {total_ticks}", True, (255, 255, 255))
cell_text = self.font.render(f"Cells: {cell_count}" if cell_count is not None else "Cells: N/A", True, (255, 255, 255))
y = self.screen_height // 2 - 80
y = self.screen_height // 2 - 40
header_rect = header.get_rect(center=(self.screen_width // 2, y))
tps_rect = tps_text.get_rect(center=(self.screen_width // 2, y + 40))
ticks_rect = ticks_text.get_rect(center=(self.screen_width // 2, y + 80))
cell_rect = cell_text.get_rect(center=(self.screen_width // 2, y + 120))
screen.blit(header, header_rect)
screen.blit(tps_text, tps_rect)
screen.blit(ticks_text, ticks_rect)
screen.blit(cell_text, cell_rect)

View File

@ -162,8 +162,6 @@ class World:
"""
Advances all objects in the world by one tick, updating their state and handling interactions.
"""
print("Ticking all objects in the world")
next_buffer: int = 1 - self.current_buffer
self.buffers[next_buffer].clear()