42 lines
1.3 KiB
Python
42 lines
1.3 KiB
Python
from __future__ import annotations
|
|
import math
|
|
from typing import Tuple, List
|
|
import pygame # type: ignore
|
|
|
|
from moon import Moon
|
|
import compute
|
|
|
|
|
|
class Apollo(Moon):
|
|
"""Fügt die Apollo-Kapsel hinzu; liest alle Werte aus Settings (env)."""
|
|
|
|
def get_apollo_angle(self) -> float:
|
|
# doppelte Winkelgeschwindigkeit, entgegengesetzte Richtung
|
|
return -2.0 * self.get_moon_angle()
|
|
|
|
def get_apollo_position(self) -> Tuple[int, int]:
|
|
theta = self.get_apollo_angle()
|
|
r = float(self.settings.apollo_orbit_radius)
|
|
rot: List[List[float]] = [
|
|
[math.cos(theta), -math.sin(theta)],
|
|
[math.sin(theta), math.cos(theta)],
|
|
]
|
|
vec: List[List[float]] = [[r], [0.0]]
|
|
res = compute.matmul(rot, vec)
|
|
mx, my = self.get_moon_position()
|
|
return int(mx + res[0][0]), int(my + res[1][0])
|
|
|
|
def draw(self, surface: pygame.Surface) -> None:
|
|
super().draw(surface)
|
|
# kleine Orbit-Linie um den Mond (optional)
|
|
pygame.draw.circle(
|
|
surface, (90, 50, 50), self.get_moon_position(), self.settings.apollo_orbit_radius, width=1
|
|
)
|
|
ax, ay = self.get_apollo_position()
|
|
pygame.draw.circle(surface, self.settings.apollo_color, (ax, ay), self.settings.apollo_radius)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
Apollo().run()
|
|
|