From a9aefef662683154c64476a57da15e450ee2ae10 Mon Sep 17 00:00:00 2001 From: OusmBlueNinja <89956790+OusmBlueNinja@users.noreply.github.com> Date: Sat, 12 Apr 2025 18:10:05 -0500 Subject: [PATCH] updated sonar logic --- submarine/main.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/submarine/main.py b/submarine/main.py index c4ff4c5..3b5f63a 100644 --- a/submarine/main.py +++ b/submarine/main.py @@ -140,8 +140,8 @@ while running: if ray_y >= seafloor[int(ray_x)]: blips.append((sonar_angle, i, now)) break + elif sonar_mode == "passive": - # Passive sonar "listens" and picks up nearby terrain noise randomly for _ in range(2): angle = random.uniform(0, 360) distance = random.randint(30, sonar_radius) @@ -185,8 +185,12 @@ while running: screen.blit(surf, (bx - 2, by - 2)) end_x = sonar_center[0] + math.cos(sweep_radians) * sonar_radius end_y = sonar_center[1] + math.sin(sweep_radians) * sonar_radius - pygame.draw.line(screen, CYAN, sonar_center, (end_x, end_y), 2) - pygame.draw.circle(screen, CYAN, sonar_center, 3) + if sonar_mode == "active": + pygame.draw.line(screen, CYAN, sonar_center, (end_x, end_y), 2) + pygame.draw.circle(screen, CYAN, sonar_center, 3) + + else: + pygame.draw.circle(screen, CYAN, sonar_center, 1) mode_text = font.render(f"Sonar: {sonar_mode.upper()} (TAB)", True, WHITE) screen.blit(mode_text, (sonar_center[0] - 60, sonar_center[1] + sonar_radius + 10))