Planet and spaceship creation, travel and destruction
This commit is contained in:
1 parent
ca9e8a2f19
commit
90e421909a
7 files changed
+307
No files matched your search
@@ -0,0 +1,67 @@
|
||||
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
|
||||
Reference in new issue
Block a user