initialer commit
This commit is contained in:
1 parent
e926d75119
commit
74776ef485
23 files changed
+445
-199
No files matched your search
@@ -0,0 +1,47 @@
|
||||
"""Animation: Die Raumkapsel Apollo kreist um den Mond."""
|
||||
|
||||
import pygame
|
||||
|
||||
from compute import rot_2D
|
||||
from moon import Moon
|
||||
|
||||
APOLLO_RADIUS = 5
|
||||
APOLLO_DISTANCE = 25
|
||||
RED = (255, 0, 0)
|
||||
|
||||
|
||||
class Apollo(Moon):
|
||||
"""Apollo kreist doppelt so schnell und entgegengesetzt um den Mond."""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
title: str = "Apollo",
|
||||
fps: int = 60,
|
||||
size: tuple[int, int] = (640, 400),
|
||||
) -> None:
|
||||
"""Legt Startposition und Rotationsmatrix von Apollo fest."""
|
||||
super().__init__(title, fps, size)
|
||||
self.position_apollo: tuple[float, float] = (APOLLO_DISTANCE, 0)
|
||||
self.rot_apollo: list[list[float]] = rot_2D(-2 * self.theta)
|
||||
|
||||
def update_game(self) -> bool:
|
||||
"""Dreht Mond und Apollo ein Stück weiter."""
|
||||
super().update_game()
|
||||
self.position_apollo = self.rotate(self.position_apollo, self.rot_apollo)
|
||||
return True
|
||||
|
||||
def draw_bodies(self) -> None:
|
||||
"""Zeichnet Erde, Mond und Apollo."""
|
||||
super().draw_bodies()
|
||||
absolute_apollo = (
|
||||
self.position_moon[0] + self.position_apollo[0],
|
||||
self.position_moon[1] + self.position_apollo[1],
|
||||
)
|
||||
pygame.draw.circle(
|
||||
self.screen, RED, self.to_screen(absolute_apollo), APOLLO_RADIUS
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
apollo = Apollo()
|
||||
apollo.run()
|
||||
Reference in new issue
Block a user