28 lines
871 B
Python
28 lines
871 B
Python
from __future__ import annotations
|
|
|
|
from .. import config
|
|
|
|
from .Point import Point
|
|
|
|
import math
|
|
class Ball:
|
|
|
|
def __init__(self) -> None:
|
|
self.size: float = config.BALL_SIZE
|
|
self.position: Point = Point(config.BALL_SPAWN_POS_X + self.size / 2, config.BALL_SPAWN_POS_Y + self.size / 2)
|
|
self.angle: float = math.pi * 0.25
|
|
self.speed: float = config.BALL_SPEED_START
|
|
|
|
def to_dict(self):
|
|
|
|
data: dict = {
|
|
"size": self.size,
|
|
"speed": self.speed,
|
|
"position": self.position.to_dict(),
|
|
"angle": self.angle,
|
|
}
|
|
|
|
return data
|
|
|
|
def __str__(self) -> str:
|
|
return f"Ball(size: {self.size}, speed: {self.speed}, director_coefficient: {self.director_coefficient}, ordinate_at_origin: {self.ordinate_at_origin}, position: {self.position})" |