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,619 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
How to convert Joy_rot values to binary values like Joy_hat? #442872
07/05/14 09:51
07/05/14 09:51
Joined: Jun 2014
Posts: 97
Lagos, Nigeria
T
tolu619 Offline OP
Junior Member
tolu619  Offline OP
Junior Member
T

Joined: Jun 2014
Posts: 97
Lagos, Nigeria
My game has a 4 directional dodge maneuver that I'm trying to map to the right analog stick. The problem is that the analog sticks return a range of values depending on how far down the player pushes them in any direction. I want my right analog stick to work like the 4-direcrional D-Pad.
To dodge to the right for example, I have tried this
Code:
if(key_cur && my.state == 1 && Energy > 10){Energy -= 10; my.state = 2;} //Dodge Right
if((joy_rot.y=255) && my.state == 1 && Energy > 10){Energy -= 10; my.state = 2;} //Dodge Right

if(my.state == 2) //Dodge Right
	   	{
	   		while(joy_rot.y > 10)
	   		wait(1);
	   		joy_rot.y = 0;
	   		dash += 8 * time_step;
	   		my.animation += 2 * time_step;
	   		ent_animate(me, "jump", my.animation, ANM_CYCLE);
	   	   c_move(me, vector(0, -dash*time_step, 0), nullvector, GLIDE | USE_POLYGON |IGNORE_PASSABLE);
	         if(dash > 59)
	         {dash = 0; my.animation = 0; my.state = 3;}
	   	}


The keyboard controls work but I haven't been able to get the joystick controls right. Depending on which "where" clause I try, I'll either get the character dodging to the right over and over again once the right stick is flicked, or he'll dodge once and become unable to move afterwards, or he won't dodge at all.

Re: How to convert Joy_rot values to binary values like Joy_hat? [Re: tolu619] #442924
07/05/14 23:10
07/05/14 23:10
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
"joy_rot.y=255"
This is NOT a comparison, you assign a value there.
Either use integer/ (int)/ floor() to get whole numbers or better use a comparison:

var input_right = (joy_rot.y > 192); // or some other value


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Re: How to convert Joy_rot values to binary values like Joy_hat? [Re: Superku] #442926
07/05/14 23:31
07/05/14 23:31
Joined: Jun 2014
Posts: 97
Lagos, Nigeria
T
tolu619 Offline OP
Junior Member
tolu619  Offline OP
Junior Member
T

Joined: Jun 2014
Posts: 97
Lagos, Nigeria
Originally Posted By: Superku
"joy_rot.y=255"
This is NOT a comparison, you assign a value there.


WOW! I can't believe I made such an obvious mistake! I know the difference so it's shameful that I didn't notice it while troubleshooting my code. Also, a direct == comparison didn't work, but using if(joy_rot.y > 192) works perfectly. It executes just once and I didn't have to refactor my code. Thanks a lot man, you're literally the second programmer on my team laugh

One last major problem I've been struggling with for weeks, after which, I'll be quiet on these forums for a while:
http://www.opserver.de/ubb7/ubbthreads.php?ubb=showflat&Number=442919#Post442919

Last edited by tolu619; 07/06/14 02:10. Reason: Added link to other thread

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