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.

AppGameKit Classic Chat / Virtual Joystick 4 direction

Author
Message
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 16th Jan 2014 22:29
Hi.
Virtual Joystick is 4 direction with parameter betwen (-1, 0, 1) but when I move virtual joystick Willing to Top or down decrease the player speed.mean Virtual joystick work at 8 direction with 4 parameter for control.and I can't find any way for disable Willing to Top or down direction. there is a way for solve this problem?
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 17th Jan 2014 12:28
Do you mean you don't want values such as "0.458264"?

If so you could convert the output to an integer:


I'm not sure what you mean by "Willing to Top or down"?

oct(31) = dec(25)
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 17th Jan 2014 15:40 Edited at: 17th Jan 2014 15:41
I don't want work (Willing up-righ, up-left, left-down, right-down) like attaced picture.

Attachments

Login to view attachments
Marl
12
Years of Service
User Offline
Joined: 19th Nov 2011
Location: Bradford, UK
Posted: 17th Jan 2014 16:19
If you don't want these movements, you could check the Y Axis and only read the x if it is zero.

But because of fine control, it would be a good idea to allow a little movement - perhaps 5% each way.
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 17th Jan 2014 16:29
Thanks Marl for your help.
could you more explanation about abs? I don't know why used abs and how work it.
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 17th Jan 2014 16:53 Edited at: 17th Jan 2014 16:54
I'm thinking a slightly better way might be to use the maximum value only:


Behdadsoft, you really should try using the help files: http://www.appgamekit.com/documentation/home.html

ABS()

oct(31) = dec(25)
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 17th Jan 2014 17:16 Edited at: 17th Jan 2014 17:21
this code don't work good. mean before when move joystick to near the up still Willing up-righ working.
already see help file and I can't see any explanation about abs. I don't know what is abs working. for this reason, I say AppGameKit is not good document.
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 17th Jan 2014 17:28
Put this code and nothing else into a brand new project and tell me it doesn't work:


I think maybe you should take a look at your own code rather than blaming everyone else's code. That code works just fine thanks

The expression you are looking for is "Diagonal" not "Willing". Not sure what translator you are using but it seems to be not translating your good manners every time either. At least not in your replies to me...

oct(31) = dec(25)
Van B
Moderator
21
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 17th Jan 2014 17:54
ABS(value) means absolute, it returns whatever the value is as a positive, meaning you can compare 2 values to see which one is greater while easily allowing for negative values.

So if the absolute of joystickx is greater than the absolute of joysticky, then the player is moving left or right so ignore the Y value, or in Baxslashes example set it to 0 so it has no effect.

I am the one who knocks...
JimHawkins
14
Years of Service
User Offline
Joined: 26th Jul 2009
Location: Hull - UK
Posted: 17th Jan 2014 18:43
Behdadsoft - I would strongly suggest that you learn the fundamentals of programming before using a powerful took like AGK. Try this:

http://www.makeuseof.com/tag/basics-of-computer-programming-variables-datatypes/

Everyone is very kind on this forum, but it's not an introduction to programming.

-- Jim - When is there going to be a release?
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 18th Jan 2014 08:10 Edited at: 18th Jan 2014 08:12
Thank baxslash for your code.
Thanks VanB for good Explanation.

Quote: "
Everyone is very kind on this forum
"

Yes,And you.

I know what is variable and basics-of-computer-programming-variables-datatypes. and know what is different between A=5; and A==5;
so I know basic but I can't good programming.do you have suggestions for improve my programming?

Thanks.
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 18th Jan 2014 09:58
i know this problem,
its because your viurtual stick is hold in a circle and not in a rectangle.
i had made a feature request for it.

instead of virtual joystick you can use a sprite and move it
at mouse down and limit this sprite position in a rectangle area.
then make a function that give you x,y as -1 to 1 from sprite position.

AGK 108 (B)19 : Windows 8.1 Pro 64 Bit : AMD Radeon HD 6670
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 18th Jan 2014 19:14
So my guess was right.the Problem is viurtual stick.
Thanks Markus for your Guide. and excuse me for My anger in other topics.
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 18th Jan 2014 21:54
yes the reason is that the virtual stick simulate a analog stick.
what you need is a stick same as a remote control have.
about other topic,no problem,there isn't just one way of doing it.

AGK 108 (B)19 : Windows 8.1 Pro 64 Bit : AMD Radeon HD 6670

Login to post a reply

Server time is: 2024-05-02 15:27:51
Your offset time is: 2024-05-02 15:27:51