Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Controller joysticks #416

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

Arman-AIi
Copy link

*Not using requestAnimationFrame anymore

Copy link
Contributor

@kenos1 kenos1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very incomplete, has no buttons support, has bad practices and needs more refinement.

@@ -8,6 +8,7 @@ import { ItemType, type ItemDefinition } from "@common/utils/objectDefinitions";
import { Vec } from "@common/utils/vector";
import $ from "jquery";
import nipplejs, { type JoystickOutputData } from "nipplejs";
import * as PIXI from "pixi.js";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please do not import everything from pixijs

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, now it only imports ticker

@@ -342,6 +343,50 @@ export class InputManager {
shootOnRelease = false;
});
}
const ticker = new PIXI.Ticker();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use Game class's pixi ticker

const ticker = new PIXI.Ticker();
ticker.stop();
ticker.add(() => {
const gamepads = navigator.getGamepads();
Copy link
Contributor

@kenos1 kenos1 Nov 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you use Game's pixi ticker, put this into its own method

const gamepads = navigator.getGamepads();
if (gamepads[0]) {
const leftJoystickMoving = gamepads[0].axes[0] !== 0 || gamepads[0].axes[1] !== 0;
const rightJoystickMoving = gamepads[0].axes[2] !== 0 || gamepads[0].axes[3] !== 0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rest in peace stick drift controllers

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps there could be a sensitivity setting to adjust when the JoystickMoving vars are considered true

ticker.stop();
ticker.add(() => {
const gamepads = navigator.getGamepads();
if (gamepads[0]) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

allow players to select their gamepad

const rightJoystickMoving = gamepads[0].axes[2] !== 0 || gamepads[0].axes[3] !== 0;
// const rightJoystickDistance = Math.sqrt(gamepads[0].axes[2] * gamepads[0].axes[2] + gamepads[0].axes[3] * gamepads[0].axes[3]);
// distance formula for stuff like throwables, USAS-12, and M590M
if (leftJoystickMoving) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably best to allow players to configure which joystick to use for what

client/src/scripts/managers/inputManager.ts Outdated Show resolved Hide resolved
this.turning = true;
const activePlayer = game.activePlayer;
if (game.console.getBuiltInCVar("cv_responsive_rotation") && !game.gameOver && game.activePlayer) {
game.activePlayer.container.rotation = this.rotation;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isn't there a better way to do this in the Player class?

client/src/scripts/managers/inputManager.ts Outdated Show resolved Hide resolved
client/src/scripts/managers/inputManager.ts Outdated Show resolved Hide resolved
const ticker = new PIXI.Ticker();
ticker.stop();
ticker.add(() => {
const gamepads = navigator.getGamepads();
Copy link
Contributor

@kenos1 kenos1 Nov 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you really need to call this method every frame, is it required?

fix: only imported ticker instead of all of pixi.js
@@ -8,7 +8,7 @@ import { ItemType, type ItemDefinition } from "@common/utils/objectDefinitions";
import { Vec } from "@common/utils/vector";
import $ from "jquery";
import nipplejs, { type JoystickOutputData } from "nipplejs";
import * as PIXI from "pixi.js";
import { Ticker } from "pixi.js";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is still wrong, use the Game update method

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants