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.

Newcomers DBPro Corner / joystick left etc.

Author
Message
Mickyfyn
20
Years of Service
User Offline
Joined: 27th Nov 2003
Location: UK
Posted: 15th Dec 2003 13:34
Hi

I am reasonably new to this and I am tyying different things to give me more experience. I can move a sprite left and right using the rightkey and leftkey commands, but I thought I would try to move the same sprite with a joystick.

sprite 1,x,400,1
movement(x)

I used this portion of code in a function psssing the x value to the function

i.e.
function movement(x)
if joystick left() = 1 then x = x -10
if x < 40 then x = 40
if joystick right() = 1 then x = x+10
if x = 600 then x = 600
endfunction x

the problem I get is the sprite automatically moves to the left, it will move right if the joystick is moved to the left, but as soon as the joystick is released the sprite moves right.

I also tried substituting if joystick x() < 0 then x = x - 10, but had the same result

The joystick works fine on bought games.

Any help would be appreciated.

Mickeyfyn
the_winch
21
Years of Service
User Offline
Joined: 1st Feb 2003
Location: Oxford, UK
Posted: 15th Dec 2003 17:56 Edited at: 15th Dec 2003 17:57
The joystick right()/left()/up()/down() commands are pretty much useless.



Joystick up will say the joystick is up if the y axis is anything less than 0. This is useless for analog sticks because they are practically never at 0 at rest and it is impossible to move the stick only in one direction.

You have to use the joystick x() and joystick y() commands to make your own joystick direction commands like this



It might be best to allow the user to adjust joy_deadzone incase there joystick is more/less sensertive that yours.

dbpro : p166mmx @ 233 : 256mb : sb 128pci : sis onboard
Mickyfyn
20
Years of Service
User Offline
Joined: 27th Nov 2003
Location: UK
Posted: 15th Dec 2003 21:13
thanks the_winch

I will try different "dead zones" until it works!

thanks again

Mickyfyn
Mickyfyn
20
Years of Service
User Offline
Joined: 27th Nov 2003
Location: UK
Posted: 16th Dec 2003 10:59
The_winch

you're great m\n, thanks for the advice.
It worked well with a dead zone of 200

Many thanks

Mickyfyn

Login to post a reply

Server time is: 2024-11-25 20:44:36
Your offset time is: 2024-11-25 20:44:36