PHP code example of venusian-surface / human-input
1. Go to this page and download the library: Download venusian-surface/human-input library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
venusian-surface / human-input example snippets
use Surface\Contracts\HumanInput\GamepadButton;
use Surface\Contracts\HumanInput\Key;
use Surface\HumanInput\MagicAliases\HumanInput;
public function loop(array $mail): SketchLoopResult
{
$keys = HumanInput::keyboard();
if ($keys->isPressed(Key::SPACE)) { $this->jump(); }
if ($keys->isDown(Key::LEFT)) { $this->x -= 2; }
$this->name .= $keys->text();
foreach (HumanInput::gameControllers() as $pad) {
$this->x += 2 * $pad->leftStick()['x'];
if ($pad->isPressed(GamepadButton::SOUTH)) { $this->jump(); }
}
return SketchLoopResult::CONTINUE;
}
while (true) {
HumanInput::poll();
if (HumanInput::keyboard()->isPressed(Key::ESCAPE)) { break; }
usleep(16_000);
}