space-truckers icon indicating copy to clipboard operation
space-truckers copied to clipboard

Add input method parameters for amount of change requested to screens for analog input support

Open jelster opened this issue 3 years ago • 0 comments

The input control system defines action methods that are mapped to functions defined in a particular screen, e.g. MOVE_LEFT(state, amt). The code currently does not read the passed in amt parameter, which prevents proper support for analog inputs (joysticks, triggers, etc).

The refactor to make should look something like this:

Before

    function MOVE_DOWN(state) {
        let up = this.truck.mesh.up;
        let currAccel = this.truck.currentAcceleration;
        this.truck.currentVelocity.addInPlace(up.scale(currAccel).negate());
    }

After

    function MOVE_DOWN(state, amt) {
        let up = this.truck.mesh.up;
        let currAccel =  isNumber(amt) ? amt : this.truck.currentAcceleration;
        this.truck.currentVelocity.addInPlace(up.scale(currAccel).negate());
    }

jelster avatar Nov 20 '21 17:11 jelster