ein docstring in moon eingefügt
apollo.py erstellt
This commit is contained in:
1 parent
0c59c96407
commit
a9ba1a66ce
2 files changed
+51
-1
No files matched your search
@@ -0,0 +1,48 @@
|
||||
"""Apollo kreist um den Mond."""
|
||||
|
||||
from compute import matvec, rot_2D
|
||||
from moon import Moon
|
||||
|
||||
APOLLO_DIST = 60 # Abstand Mond -> Apollo
|
||||
APOLLO_RADIUS = 5
|
||||
RED = (255, 0, 0)
|
||||
FAKTOR = -2 # doppelte Drehung, entgegengesetzte Richtung
|
||||
|
||||
|
||||
class Apollo(Moon):
|
||||
"""Apollo kreist doppelt so schnell und gegenläufig um den Mond."""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
title: str = "Apollo",
|
||||
fps: int = 60,
|
||||
size: tuple[int, int] = (640, 400),
|
||||
) -> None:
|
||||
super().__init__(title, fps, size)
|
||||
self.apollo_pos = self.apollo_startposition()
|
||||
|
||||
def apollo_startposition(self) -> list[float]:
|
||||
"""Startposition von Apollo als Vektor relativ zum Mond."""
|
||||
return [APOLLO_DIST, 0.0]
|
||||
|
||||
def drehe_apollo(self, vektor: list[float]) -> list[float]:
|
||||
"""Dreht Apollo mit doppelter, gegenläufiger Winkelgeschwindigkeit."""
|
||||
return matvec(rot_2D(FAKTOR * self.angle), vektor)
|
||||
|
||||
def update_game(self) -> bool:
|
||||
super().update_game()
|
||||
self.apollo_pos = self.drehe_apollo(self.apollo_pos)
|
||||
return True
|
||||
|
||||
def draw_space(self) -> None:
|
||||
super().draw_space()
|
||||
apollo_vektor = [
|
||||
self.pos[0] + self.apollo_pos[0],
|
||||
self.pos[1] + self.apollo_pos[1],
|
||||
]
|
||||
self.draw_body(self.absolut(apollo_vektor), APOLLO_RADIUS, RED)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
apollo = Apollo()
|
||||
apollo.run()
|
||||
Reference in new issue
Block a user