initialer commit
This commit is contained in:
1 parent
b782603ed2
commit
e926d75119
7 files changed
+324
No files matched your search
@@ -0,0 +1,33 @@
|
||||
import pygame
|
||||
from aufgabenblatt_1.hausaufgaben.compute import matmul
|
||||
from aufgabenblatt_1.hausaufgaben.transponieren import transpose, rot_2D
|
||||
from game import Game
|
||||
|
||||
EARTH_RADIUS = 30
|
||||
MOON_RADIUS = 10
|
||||
BLACK = (0, 0, 0)
|
||||
WHITE = (255, 255, 255)
|
||||
BLUE = (0, 0, 255)
|
||||
|
||||
"""Der Mond kreist um die Erde."""
|
||||
class Moon(Game):
|
||||
def __init__(self, title: str = "Moon", fps: int = 60, size: tuple[int, int] = (640, 400),) -> None:
|
||||
"""Legt Startposition, Drehwinkel und Rotationsmatrix fest."""
|
||||
super().__init__(title, fps, size)
|
||||
self.position_moon = (120, 0) # relativ zur Erde
|
||||
theta = 0.01 # Drehwinkel pro Bild im Bogenmaß
|
||||
self.rot_moon = rot_2D(theta)
|
||||
|
||||
def update_game(self) -> bool:
|
||||
"""Dreht den Mond ein Stück weiter."""
|
||||
point = transpose([list(self.position_moon)]) # [x, y] -> [[x], [y]]
|
||||
result = matmul(self.rot_moon, point) # [[x'], [y']]
|
||||
self.position_moon = (result[0][0], result[1][0])
|
||||
return True
|
||||
|
||||
def draw_game(self) -> None:
|
||||
"""Zeichnet Erde und Mond."""
|
||||
# Bildschirm löschen, Erde und Mond zeichnen, Bild anzeigen
|
||||
|
||||
if __name__ == "__main__":
|
||||
# Moon-Objekt erzeugen und starten
|
||||
Reference in new issue
Block a user