about summary refs log tree commit diff
path: root/src/gui/minimap_sprite.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/minimap_sprite.py')
-rw-r--r--src/gui/minimap_sprite.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/gui/minimap_sprite.py b/src/gui/minimap_sprite.py
new file mode 100644
index 0000000..fc71f9f
--- /dev/null
+++ b/src/gui/minimap_sprite.py
@@ -0,0 +1,27 @@
+import math
+
+import pygame
+from pygame.locals import *
+
+from simulation import Simulation
+
+class Sprite_Minimap(pygame.sprite.Sprite):
+    def __init__(self, simulation: type[Simulation], radius: int):
+        super().__init__()
+        self.simulation = simulation
+        self.radius = radius
+
+    def update(self, display_width, display_height):
+        self.image = pygame.Surface([self.radius * 2, self.radius * 2], pygame.SRCALPHA)
+
+        #body
+        pygame.draw.circle(self.image, (0, 255, 0), (self.radius, self.radius), self.radius, width=2)
+        
+        #rocket position (TODO, show actual position in relation to surface. allow zoom?)
+        normalized_x = math.sin(math.radians(self.simulation.angle_of_position_with_respect_to_origin())) * (self.radius)
+        normalized_y = math.cos(math.radians(self.simulation.angle_of_position_with_respect_to_origin())) * (self.radius)
+        normalized_rocket_pos = [self.radius + normalized_x, self.radius - normalized_y]
+        pygame.draw.circle(self.image, (255, 0, 0), normalized_rocket_pos, 4)
+
+        self.rect = self.image.get_rect()
+        self.rect.topright = [display_width, 0]
\ No newline at end of file