Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Require Help with Dual Joystick operation...

Author
Message
YAURAH
19
Years of Service
User Offline
Joined: 12th Apr 2007
Location: Everywhere
Posted: 6th May 2012 15:31


We need some help here at the lab...
I have the multijoy plugin, but would prefer the DBpro original method for two simultaneous joysticks control... Ive attached code, and anyone that can help, it would be greatly appreciated.

what I am trying to accomplish in the code eventually is the main robot will have two arms (each arm controlled by a separate joystick)
for now I am testing by seeing if we can get each joystick to have control over the frame...unfortunately I am not familiar with the control device method...

`H.A.R.M. - ( Heavy Armored Robotic Mech )
`Designed by Christopher S. Johnson AKA: YZ
`Developed for UNITUS at HOLY SCIENTIFIC LABS (all rights reserved) (c) 5/2/2012

SET DISPLAY MODE DESKTOP WIDTH(), DESKTOP HEIGHT(), 32
maximize window
hide mouse



make matrix 1,1000,1000,50,50
randomize matrix 1,20
LOAD IMAGE "ground1.jpg",1
PREPARE MATRIX TEXTURE 1,1,1,1
update matrix 1

LOAD OBJECT "HARM1.x",1
POSITION OBJECT 1,500,50,500
SCALE OBJECT 1,80,80,80
SET OBJECT cull 1,0
TURN OBJECT LEFT 1,180

MAKE CAMERA 1
POSITION CAMERA 1,LIMB POSITION X(1,6),LIMB POSITION Y(1,6),LIMB POSITION Z(1,6)
COLOR BACKDROP 1,rgb(50,50,70)
TURN CAMERA LEFT 1,360

MAKE CAMERA 2
POSITION CAMERA 2,object position x(1),object position y(1)+20,object position z(1)-100
set camera view 2, 10, 10, 300, 300
point CAMERA 2,object position x(1),object position y(1),object position z(1)


global speed# as float
global movement as integer
speed#=0.00
movement=0


SET CONTROL DEVICE INDEX 0
SET CONTROL DEVICE "WingMan Force 3D"

SET CONTROL DEVICE INDEX 1
SET CONTROL DEVICE "WingMan Attack 2"

do
movement=0
if keystate(17)=1 then speed#=curvevalue(-1,speed#,10) : movement=1
if keystate(31)=1 then speed#=curvevalue(1,speed#,10) : movement=1
if keystate(30)=1 then turn OBJECT left 1,1
if keystate(32)=1 then turn OBJECT right 1,1
if keystate(30)=1 then turn CAMERA left 1,1
if keystate(32)=1 then turn CAMERA right 1,1

if JOYSTICK up() =1 then speed#=curvevalue(-1,speed#,10) : movement=1
if JOYSTICK down() =1 then speed#=curvevalue(1,speed#,10) : movement=1
if JOYSTICK left() =1 then turn OBJECT left 1,1
if JOYSTICK right() =1 then turn OBJECT right 1,1
if JOYSTICK left() =1 then turn camera left 1,1
if JOYSTICK right() =1 then turn camera right 1,1



if CONTROL DEVICE Z() =-1 then speed#=curvevalue(-1,speed#,10) : movement=1
if CONTROL DEVICE Z() =1 then speed#=curvevalue(1,speed#,10) : movement=1
if CONTROL DEVICE X() =-1 then turn OBJECT left 1,1
if CONTROL DEVICE X() =1 then turn OBJECT right 1,1
if CONTROL DEVICE X() =-1 then turn camera left 1,1
if CONTROL DEVICE X() =1 then turn camera right 1,1




if movement=0 then speed#=curvevalue(0,speed#,10)
move object 1,speed#
yROTATE OBJECT 1,wrapvalue(object angle y(1)-(mousemovex()/0.8))
xROTATE OBJECT 1,wrapvalue(object angle x(1)-(mousemovey()*0.2))
position object 1,object position x(1),get ground height(1,object position x(1),object position z(1))+2.5,object position z(1)

SET CAMERA TO FOLLOW 1,LIMB POSITION X(1,6),LIMB POSITION Y(1,6)+3,LIMB POSITION Z(1,6)-5,0,-5,-5,1,0
SET CAMERA TO FOLLOW 2,object POSITION X(1),object POSITION Y(1)+30,object POSITION Z(1)-70,0,0,0,1,0

sync
loop

CSJ 7000
YAURAH
19
Years of Service
User Offline
Joined: 12th Apr 2007
Location: Everywhere
Posted: 6th May 2012 15:33
sorry the code capture did not work correctly for me...



CSJ 7000
Millenium7
21
Years of Service
User Offline
Joined: 13th Dec 2004
Location:
Posted: 7th May 2012 08:43
You'll need to use a plugin that supports multiple input devices. I've never used the inbuilt dbpro joystick section so dunno if it can do that

I've used some sort of xbox360 controller plugin in one of my projects and it allows you to specify a number in the command
i.e.


so my guess is find a 3rd party plugin that handles multiple joysticks
Jimpo
21
Years of Service
User Offline
Joined: 9th Apr 2005
Location:
Posted: 14th May 2012 20:13
DBPro has built in support for multiple joysticks. My Dego game worked with up to four joysticks without using any plugins for it. Here's some sample code that shows how it works:



This will let you move two cubes around the screen using two joysticks. The setup code was copied and pasted from Dego, and was written years ago, so I might not be able to go into detail on how it works.

Hope this helps!

YAURAH
19
Years of Service
User Offline
Joined: 12th Apr 2007
Location: Everywhere
Posted: 14th May 2012 23:25
Thank you Millinium7, and Jimpo...

I have solved the issue using multijoy plugin, but your info really helps for future recompilations, and experiments Jimpo...

thnx again

CSJ - Holy Scientific/UNITUS

CSJ 7000

Login to post a reply

Server time is: 2026-07-22 00:35:19
Your offset time is: 2026-07-22 00:35:19