about summary refs log tree commit diff
path: root/src/gui/minimap_sprite.py
diff options
context:
space:
mode:
authorBaitinq <you@example.com>2022-02-12 21:20:37 +0000
committerBaitinq <you@example.com>2022-02-12 21:20:37 +0000
commit5edac23f6ab3f37167c24331ac8b17c673cbf732 (patch)
treea26c8e99040aa1bb8a0fdf223b8c7ae7ed175f84 /src/gui/minimap_sprite.py
parentImplemented proper 2d gravity (diff)
downloadOSLS-5edac23f6ab3f37167c24331ac8b17c673cbf732.tar.gz
OSLS-5edac23f6ab3f37167c24331ac8b17c673cbf732.tar.bz2
OSLS-5edac23f6ab3f37167c24331ac8b17c673cbf732.zip
Fixed drag calculation and added orbit info sprite
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