game: multiplayer: work

This commit is contained in:
2024-05-15 13:41:24 +02:00
parent efd8d53f6c
commit 400a91df3e
8 changed files with 31 additions and 23 deletions

View File

@ -10,18 +10,14 @@ import math
class Ball:
def __init__(self) -> None:
self.size: float
self.position: Position
self.angle: float
self.speed: float
self.reset()
self.speed = 0
self.size: float = config.BALL_SIZE
self.position: Position = Position(Point(config.BALL_SPAWN_POS_X + self.size / 2, config.BALL_SPAWN_POS_Y + self.size / 2), time.time())
self.angle: float = 0
self.speed: float = 0
def reset(self) -> None:
self.size = config.BALL_SIZE
self.position = Position(Point(config.BALL_SPAWN_POS_X + self.size / 2, config.BALL_SPAWN_POS_Y + self.size / 2), time.time())
self.angle = math.pi * 0
def reset(self, target: Point) -> None:
self.position: Position = Position(Point(config.BALL_SPAWN_POS_X + self.size / 2, config.BALL_SPAWN_POS_Y + self.size / 2), time.time())
self.angle = math.atan2(target.y - self.position.location.y, target.x - self.position.location.x)
self.speed = config.BALL_SPEED_START
def to_dict(self) -> dict: