Game Development Community

Can't Get Right Axis Working

by Matthew Haralovich · in Hardware Issues · 08/22/2006 (4:13 pm) · 0 replies

I've been trying to get the right joystick axis working in TGB 1.1.1 (Windows). Here is my test code.

--

$enableDirectInput = "1";
activateDirectInput();
enableJoystick();

function LShip::onLevelLoaded(%this, %scenegraph) {
$leftShip = %this;
%this.axisVelocity = 50;
moveMap.bind(joystick0, xaxis, leftShipX);
moveMap.bind(joystick0, yaxis, leftShipY);
}

function leftShipX(%val) {
$leftShip.setLinearVelocityX($leftShip.axisVelocity * %val);
}

function leftShipY(%val) {
$leftShip.setLinearVelocityY($leftShip.axisVelocity * %val);
}

function RShip::onLevelLoaded(%this, %scenegraph) {
$rightShip = %this;
%this.axisVelocity = 50;
moveMap.bind(joystick0, rxaxis, rightShipX);
moveMap.bind(joystick0, ryaxis, rightShipY);
}

function rightShipX(%val) {
$rightShip.setLinearVelocityX($rightShip.axisVelocity * %val);
}

function rightShipY(%val) {
$rightShip.setLinearVelocityY($rightShip.axisVelocity * %val);
}

--

LShip moves around with the left axis. RShip does nothing. Reversing their binds results in RShip moving instead. The gamepad I'm using functions in pygame and Zap with both axes.

Please tell me if you can get this script to work, or if I need to make changes to it.

About the author

Recent Threads