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
1 registered members (TipmyPip), 18,633 guests, and 5 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
Joystick problems. #247453
01/20/09 23:36
01/20/09 23:36
Joined: May 2006
Posts: 27
B
BrockA Offline OP
Newbie
BrockA  Offline OP
Newbie
B

Joined: May 2006
Posts: 27
Heyy there..
I was wondering if somebody could take a quick look at my code and possibly explain what I'm doing wrong? Right now I'm trying to code movement of a Entity with a Playstation Joystick.. The problem is the joy_force.x, because it's only controlling the pan of the Entity in ONE direction. As you can imagine there is 4-DPad buttons.. Up,Down,Left, and Right. and It only moves to the right. I want to be able to move the entity to the left, and to the right.

How would I go about fixing my code to make it work?

Thanks for any help!
-Brock



Code:
 	while(1)
	{
		wait(1);
		
		if(joy_force.y)
		{
			c_move (my, vector(6*time_step,0,0), nullvector, GLIDE);
   		wait (1);
		}
		
		if (joy_force.x)
		{	
			my.pan += 8*time_step;
		}
		
		if (!joy_force.y)
		{
			idle_percent = (idle_percent +2*time_step)%100;
			ent_animate(me,"stand",idle_percent,ANM_CYCLE);
		}
		else
		{
			ent_animate(me,"walk",walk_percent,ANM_CYCLE);
			walk_percent += 10 * time_step; 
		}	
		if (joy_2 && joy_force.y)
		{
			ent_animate(me,"run",run_percent,ANM_CYCLE);
			run_percent = 7* time_step;
		}
	}	


Re: Joystick problems. [Re: BrockA] #247852
01/22/09 23:16
01/22/09 23:16
Joined: Aug 2005
Posts: 512
Bayern
Schmerzmittel Offline
User
Schmerzmittel  Offline
User

Joined: Aug 2005
Posts: 512
Bayern
Hiho..

i dont know if this work with C-Script.

But you can define your keys like this:

Code:
var RIGHT, LEFT; 
 
function CheckKeys()
{

RIGHT   =   (joy_force.y > 0);
LEFT    =   (joy_force.y < 0);

}



Then you can use like this:

Code:
if(RIGHT - LEFT)
{
c_move (my, vector(6*time_step,0,0), nullvector, GLIDE);
}
 



Ah..and in your code you can leave the wait(1).
In a if-decision you dont need a wait(1).

Hope this helps. The code works for me in Lite-C. I hope in C-Script too.

Greetings
Schmerzmittel


A7 Com V7.80
Re: Joystick problems. [Re: Schmerzmittel] #248182
01/25/09 02:57
01/25/09 02:57
Joined: May 2006
Posts: 27
B
BrockA Offline OP
Newbie
BrockA  Offline OP
Newbie
B

Joined: May 2006
Posts: 27
I appreciate the suggestion but I just tried it and it didnt work :'(

It said something about too many parameters in the CheckKeys function with RIGHT and LEFT

Possible aswer [Re: BrockA] #248213
01/25/09 13:01
01/25/09 13:01
Joined: Apr 2006
Posts: 159
Latvija
Arrovs Offline
Member
Arrovs  Offline
Member

Joined: Apr 2006
Posts: 159
Latvija
//First
var virziens;//left and right
//ad if you want more vars then need
var smtg_else;

function kustiba//movement
{
while(1)//this is for example
{
//this code below you place in your code
if(joy_force.y>0){virziens=6*time_step}
if(joy_force.y<0){virziens=-6*time_step}
//here you move in that direction now to which you press
c_move(my,vector(virziens,0,0),nullvector,GLIDE);
wait(1);
}
}


Arrovs once will publish game
Re: Possible aswer [Re: Arrovs] #248315
01/26/09 00:02
01/26/09 00:02
Joined: May 2006
Posts: 27
B
BrockA Offline OP
Newbie
BrockA  Offline OP
Newbie
B

Joined: May 2006
Posts: 27
Thanks Arroys for the help, I changed it around a bit to work the way I wanted it to but your idea helped out alot. Thanks again! smile

Re: Possible aswer [Re: BrockA] #249233
02/01/09 10:33
02/01/09 10:33
Joined: Apr 2006
Posts: 159
Latvija
Arrovs Offline
Member
Arrovs  Offline
Member

Joined: Apr 2006
Posts: 159
Latvija
nice to hear! If only need something - only ask!


Arrovs once will publish game

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