<span class="touchpad">The game is controlled through touch movements on an on-screen touchpad. Movements correspond directly to the play area.</span>
<span class="thumbstick">The game is controlled through touch movements on an on-screen thumbstick. Directional movements steer the cursor.</span>
<span class="keyboard">The game is controlled through arrow or WASD key presses. Key rebinding and additional accessibility options are available.</span>
-<span class="gamepad">The game is controlled using the thumbstick or d-pad of an attached gamepad accessory.</span>
+<span class="gamepad">The game is controlled using the thumbstick of an attached gamepad accessory.</span>
</p>
</div>
<div class="graphics">
let delta = Math.min(game.view.clock.getDeltaTime(), 1 / 12) * (game.settings['difficulty']['speed'] / 100);
game.timeProgress = (game.timeProgress + delta);
+ if(game.settings['controls'] == 'gamepad') {
+ let speedScale = 7.0;
+ let deadZone = 0.2;
+ let speedX = [];
+ let speedY = [];
+ for(let gamepad of game.ui.gamepads) {
+ let sx = gamepad.axes[0];
+ if(Math.abs(sx) < deadZone) {
+ sx = 0.0;
+ }
+ speedX.push(sx);
+ let sy = gamepad.axes[1];
+ if(Math.abs(sy) < deadZone) {
+ sy = 0.0;
+ }
+ speedY.push(sy);
+ }
+ if(speedX.length > 0) {
+ speedX = speedX.reduce((s, a) => s + a, 0) / speedX.length;
+ } else {
+ speedX = 0;
+ }
+ if(speedY.length > 0) {
+ speedY = speedY.reduce((s, a) => s + a, 0) / speedY.length;
+ } else {
+ speedY = 0;
+ }
+ game.controls.speedX = speedScale * speedX;
+ game.controls.speedY = -1 * speedScale * speedY;
+ }
+
const maxPinwheelSpeed = 8.0;
const maxPinwheelDistance = 5.0;
game.controls.speedX += delta * game.controls.accelX;
state: 'loadingAssets',
ui: {
root: document.querySelector('.game-upintheair'),
+ gamepads: [],
},
settings: {},
};
}
}
});
+window.addEventListener('gamepadconnected', (e) => {
+ game.ui.gamepads.push(e.gamepad);
+});
+window.addEventListener('gamepaddisconnected', (e) => {
+ if(game.ui.gamepads.includes(e.gamepad)) {
+ game.ui.gamepads.splice(game.ui.gamepads.indexOf(e.gamepad), 1);
+ }
+});
game.ui.root.querySelector('.ui-page.pause button.title').addEventListener('click', () => {
reset(game);
});