Gamestudio Links
Zorro Links
Newest Posts
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
4 registered members (AbrahamR, 7th_zorro, dr_panther, 1 invisible), 702 guests, and 6 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 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 | chip programmers | 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