From cb85e8b86c580f9694a9f3ada6d50d36a41d8ee7 Mon Sep 17 00:00:00 2001 From: erik detzel Date: Thu, 22 Oct 2026 14:15:18 +0200 Subject: [PATCH] =?UTF-8?q?Opencode=20gesagt=20er=20soll=20die=20Docstring?= =?UTF-8?q?s=20und=20Type=20hints=20noch=20erg=C3=A4nzen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apollo.py | 4 ++-- compute.py | 7 +++---- game.py | 6 ++---- moon.py | 10 ++++++---- 4 files changed, 13 insertions(+), 14 deletions(-) diff --git a/apollo.py b/apollo.py index fe2c895..7030581 100644 --- a/apollo.py +++ b/apollo.py @@ -23,7 +23,7 @@ class Apollo(Moon): super().__init__(title, fps, size) self.position_apollo: Point = (APOLLO_DISTANCE, 0.0) # relativ zum Mond # doppelte Winkelgeschwindigkeit, entgegengesetzte Drehrichtung - self.rot_apollo = rot_2d(-2 * self.theta, unit="rad") + self.rot_apollo: list[list[float]] = rot_2d(-2 * self.theta, unit="rad") def update_game(self) -> bool: """Bewegt erst den Mond, dann Apollo.""" @@ -44,4 +44,4 @@ class Apollo(Moon): if __name__ == "__main__": apollo = Apollo() - apollo.run() \ No newline at end of file + apollo.run() diff --git a/compute.py b/compute.py index 0f18bd8..e6eec0f 100644 --- a/compute.py +++ b/compute.py @@ -8,7 +8,7 @@ from typing import Literal from tabulate import tabulate -__all__ = ["matmul", "rot_2d", "rotate", "transpose"] +__all__ = ["matmul", "print_matrix", "rot_2d", "rotate", "transpose"] _NUMERIC_TYPES = (int, float) @@ -259,7 +259,6 @@ if __name__ == "__main__": print() print("All tests passed.") - #This is a test commit + # This is a test commit print("This is a test") -if __name__ == "__main__": - print(tabulate(rot_2d(1.0))) \ No newline at end of file + print(tabulate(rot_2d(1.0))) diff --git a/game.py b/game.py index e88c245..5098ecd 100644 --- a/game.py +++ b/game.py @@ -75,9 +75,7 @@ class Game: Returns: ``False`` bei ``pygame.QUIT``, sonst ``True``. """ - if event.type == pygame.QUIT: - return False - return True + return event.type != pygame.QUIT def update_game(self) -> bool: """Aktualisiert den Spielzustand um einen Frame. @@ -95,4 +93,4 @@ class Game: """Startet das Spiel: Initialisierung, Hauptschleife, Beenden.""" self.init_game() self.game_loop() - self.exit_game() \ No newline at end of file + self.exit_game() diff --git a/moon.py b/moon.py index 817c57f..d66dbf0 100644 --- a/moon.py +++ b/moon.py @@ -1,3 +1,5 @@ +"""Simulation eines um die Erde kreisenden Mondes mit pygame.""" + import pygame from compute import matmul, rot_2d, transpose @@ -25,9 +27,9 @@ class Moon(Game): """Legt Startposition, Drehwinkel und Rotationsmatrix fest.""" super().__init__(title, fps, size) self.position_moon: Point = (MOON_DISTANCE, 0.0) # relativ zur Erde - self.theta = 0.01 # radian per frame - self.rot_moon = rot_2d(self.theta, unit="rad") - self.center = (size[0] // 2, size[1] // 2) + self.theta: float = 0.01 # radian per frame + self.rot_moon: list[list[float]] = rot_2d(self.theta, unit="rad") + self.center: tuple[int, int] = (size[0] // 2, size[1] // 2) @staticmethod def rotate(point: Point, rotation: list[list[float]]) -> Point: @@ -64,4 +66,4 @@ class Moon(Game): if __name__ == "__main__": moon = Moon() - moon.run() \ No newline at end of file + moon.run()