UK

SONIC PHP

від davidnurdin · Платформери
5,0 (1)
▶ Грати 💬 Відгуки Сирці 🕘 Версії Редагувати GitHub
. / src / Util / Vector.php · commit a20d00e
<?phpnamespace App\Util;trait Vector{    public function __construct(protected float $x = 0, protected float $y = 0)    {    }    public function setXY(float $x, float $y): void    {        $this->x = $x;        $this->y = $y;        if (is_callable([$this, 'emit'])) {            $this->emit('positionChanged', [$this->x, $this->y]);        }    }    public function getX(): int    {        return (int)round($this->x);    }    public function getY(): int    {        return (int)round($this->y);    }    public function setX(float $x): void    {        $this->x = $x;        if (is_callable([$this, 'emit'])) {            $this->emit('positionChanged', [$this->x, $this->y]);        }    }    public function setY(float $y): void    {        $this->y = $y;        if (is_callable([$this, 'emit'])) {            $this->emit('positionChanged', [$this->x, $this->y]);        }    }}