FR

Slave Rift

par tueb2024 · Tir
5,0 (1)
▶ Jouer 💬 Avis Sources 🕘 Versions Éditer GitHub
games/slave-rift / patches / JumPHP / Input / Mouse.php · commit 9ea6094
<?phpnamespace JumPHP\Input;/** * Local Slave Rift extension of JumPHP's Mouse input. * Keeps the upstream API and exposes the SDL wheel delta for upgrade menus. */class Mouse{    public float $x = 0;    public float $y = 0;    public int $wheelY = 0;    /** @var array<int, bool> */    private array $held = [];    /** @var array<int, bool> */    private array $pressed = [];    /** @var array<int, bool> */    private array $released = [];    public function move(float $x, float $y): void    {        $this->x = $x;        $this->y = $y;    }    public function wheel(int $y): void    {        $this->wheelY += $y;    }    public function down(int $button): void    {        $this->held[$button] = true;        $this->pressed[$button] = true;    }    public function up(int $button): void    {        unset($this->held[$button]);        $this->released[$button] = true;    }    public function isHeld(int $button = 1): bool    {        return isset($this->held[$button]);    }    public function isPressed(int $button = 1): bool    {        return isset($this->pressed[$button]);    }    public function isReleased(int $button = 1): bool    {        return isset($this->released[$button]);    }    public function resetTransientStates(): void    {        $this->pressed = [];        $this->released = [];        $this->wheelY = 0;    }}