Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
3 registered members (TipmyPip, AndrewAMD, NewbieZorro), 16,655 guests, and 7 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
c_move and joy_force #159537
10/08/07 01:20
10/08/07 01:20
Joined: Mar 2005
Posts: 134
J
jeffmorris Offline OP
Member
jeffmorris  Offline OP
Member
J

Joined: Mar 2005
Posts: 134
In the Lite-C Workshop 15 tutorial, you learn how to write code to control the camera using the joystick. In the Lite-C Workshop 18 tutorial, you learn how to write code to control the car using the keyboard. I modified the code so that I can move the car forward and backward using the keyboard. How do I control the car using joystick?

Code:

action my_car()
{
while (1)
{
if (key_a && key_cuu)
my.pan += 3*time_step;
if (key_s && key_cuu)
my.pan -= 3*time_step;
if (key_a && key_cud)
my.pan -= 3*time_step;
if (key_s && key_cud)
my.pan += 3*time_step;
if (key_cuu)
c_move (my, vector(15*time_step, 0, 0), nullvector, GLIDE);
if (key_cud)
c_move (my, vector(-15*time_step, 0, 0), nullvector, GLIDE);
wait (1);
}
}



Re: c_move and joy_force [Re: jeffmorris] #159538
10/09/07 11:14
10/09/07 11:14
Joined: Mar 2005
Posts: 134
J
jeffmorris Offline OP
Member
jeffmorris  Offline OP
Member
J

Joined: Mar 2005
Posts: 134
I'm not sure if this is the right way to use c_move and joy_force commands to move the car. Is it possible to attach the camera to the car and move them together?

Code:

action my_car()
{
while (1)
{
if (joy_force.y>0)
my.pan -= joy_force.x*time_step;
if (joy_force.y<0)
my.pan += joy_force.x*time_step;
if (joy_force.y>0)
c_move (my, vector(15*time_step, 0, 0), nullvector, GLIDE);
if (joy_force.y<0)
c_move (my, vector(-15*time_step, 0, 0), nullvector, GLIDE);
wait (1);
}
}



Re: c_move and joy_force [Re: jeffmorris] #159539
10/09/07 16:22
10/09/07 16:22
Joined: Aug 2005
Posts: 1,558
HK
V
vlau Offline
Serious User
vlau  Offline
Serious User
V

Joined: Aug 2005
Posts: 1,558
HK
For joystick control, you may try the following code :

Code:

var speed = 5; // play with 5
var jForce;
action my_car()
{
while(1)
{
jForce = (joy_6 - joy_5);
// move forward and backward
c_move(my,vector((joy_6-joy_5)*speed*time_step,0,0),nullvector,GLIDE);
// turn left and right
c_rotate(my,vector(-joy_force.x*time_step*jForce,0,0),USE_AXIS);

// follow cam
vec_set(camera.x,vector(-200,0,40)); // play with the vec position
vec_rotate(camera.x,my.pan);
vec_add(camera.x,my.x);

//camera.pan += 0.2 * ang (my.pan - camera.pan) * time_step; // line A

vec_set(camera.pan,my.pan); // line B

wait(1);
}
}



If you want a little bit camera lag uncomment line A and comment out line B.
My joystick may not the same as yours, try to modify those joy_???? youself.

Have fun!

Re: c_move and joy_force [Re: vlau] #159540
10/09/07 23:45
10/09/07 23:45
Joined: Mar 2005
Posts: 134
J
jeffmorris Offline OP
Member
jeffmorris  Offline OP
Member
J

Joined: Mar 2005
Posts: 134
Vlau, Can you modify your joystick code so that pressing the triggers on XBOX 360 controller moves the car? If that's not possible, use the Y axis on the left thumbstick to move the car?

Re: c_move and joy_force [Re: jeffmorris] #159541
10/10/07 07:30
10/10/07 07:30
Joined: Aug 2005
Posts: 1,558
HK
V
vlau Offline
Serious User
vlau  Offline
Serious User
V

Joined: Aug 2005
Posts: 1,558
HK
I don't have XBOX360 so I can't test it for you.
Actually, you're free to modify the above code
yourself and it is very easy.

There are many buttons available such as :
joy_1...12, joy2_1...12 joy_buttons...etc.
They are all described well in the manual.

Re: c_move and joy_force [Re: vlau] #159542
10/12/07 11:52
10/12/07 11:52
Joined: Mar 2005
Posts: 134
J
jeffmorris Offline OP
Member
jeffmorris  Offline OP
Member
J

Joined: Mar 2005
Posts: 134
On my XBOX360 gamepad, the triggers use Z Axis and the right thumbstick (joystick) uses X Rotation and Y Rotation. Does Game Studio A7 support XBOX360 gamepads? If so, how do I set up Game Studio programs for XBOX360 gamepads?

Re: c_move and joy_force [Re: jeffmorris] #159543
10/12/07 13:55
10/12/07 13:55
Joined: Aug 2005
Posts: 1,558
HK
V
vlau Offline
Serious User
vlau  Offline
Serious User
V

Joined: Aug 2005
Posts: 1,558
HK
Maybe this thread could help.

Re: c_move and joy_force [Re: vlau] #159544
10/13/07 09:56
10/13/07 09:56
Joined: Mar 2005
Posts: 134
J
jeffmorris Offline OP
Member
jeffmorris  Offline OP
Member
J

Joined: Mar 2005
Posts: 134
vlau, Thanks for the plug-in for XBOX360 gamepad support. The plug-in was written for A6 and I think that it needs to be updated for A7. I couldn't compile the Xbox_dll.wdl file because the "define" command was an undeclared identifier.

Re: c_move and joy_force [Re: jeffmorris] #159545
10/14/07 10:02
10/14/07 10:02
Joined: Mar 2005
Posts: 134
J
jeffmorris Offline OP
Member
jeffmorris  Offline OP
Member
J

Joined: Mar 2005
Posts: 134
I think that the plug-in for XBOX360 gamepad support is not compatible with A7. After compiling the game level that includes the plug-in for XBOX360 gamepad support and trying to run the game level, I get the Microsoft send/don't send message.


Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1