from dataclasses import dataclass, field from random import randrange def default_rotation(): return randrange(0, 359) @dataclass class Vector2D: x: float y: float def __iadd__(self, other): self.x += other.x self.y += other.y return self def __add__(self, other): return Vector2D( x=self.x + other.x, y=self.y + other.y, ) def __sub__(self, other): return Vector2D( x=self.x - other.x, y=self.y - other.y, ) def __abs__(self): return (self.x * self.x + self.y * self.y) ** 0.5 @dataclass class Position(Vector2D): pass @dataclass class Target(Vector2D): pass @dataclass class Speed(Vector2D): pass @dataclass class Color: value: tuple[int, int, int, int] @dataclass class Radius: value: int @dataclass class SpaceShipMarker: pass @dataclass class PlanetMarker: pass