bottom = $floorY; } protected function tick(array $player): void { } /** Top Sonic stands on. */ public function getTop(): float { return $this->bottom - ($this->pressed ? 10 : 15); } /** Floor under the switch. */ public function getBottom(): float { return $this->bottom; } /** Called every frame with "is Sonic standing on it": returns true when the switch gets pressed. */ public function setPressed(bool $pressed): bool { $justPressed = $pressed && !$this->pressed; $this->pressed = $pressed; return $justPressed; } public function render(float $cameraX, float $cameraY): void { $sprite = $this->pressed ? self::DOWN : self::UP; $this->blit($sprite, $this->x, $this->bottom - $sprite[3], $cameraX, $cameraY); } }