The Daily Click ::. Forums ::. Klik Coding Help ::. Abs( A )+ Abs( B )
 

Post Reply  Post Oekaki 
 

Posted By Message

CakeSpear



Registered
  28/01/2004
Points
  112
30th December, 2009 at 16:13:18 -

I'm having a hard time getting my head around something here. I suck at explaining this, but I'm going to try never the less. This is not directly related to my problem, but might help me understand it or get closer to the solution. It might make me solve it.

I have value A and value B, both ranging from -6 to +6.
I'm looking for an equation preferably, or any other way like a set of conditions, to make Abs( A )+ Abs( B ) never equal more than 6. Using MMF2

Any thoughts or solutions to this?


 
n/a

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1971

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
30th December, 2009 at 16:18:20 -

Min( Abs(A) + Abs(B), 6 )

If that's not it, you'll have to try and explain a bit better...

 
n/a

CakeSpear



Registered
  28/01/2004
Points
  112
30th December, 2009 at 17:26:08 -

OK i will try... Lets say
value A ranging from -6 to +6 is a vertical speed(in pixels), for moving forwards and backwards
value B ranging from -6 to +6 is a horizontal speed(in pixels), for moving left and right
And i want the maximum speed(pixels moved) to be 6.

But if you are going at, lets say, full speed forward and turn a full right or left; your speeds would now be A=6 B=6 or A=6 B=-6. Either way your total speed now is Abs( A ) plus Abs( B ), 6 plus 6 = 12(pixels moved). In this particular case A and B would logically be altered to A=3 B=3, by doing something.

Trying to put the 'solution' values into values C and D and not altering the original values A and B, seems like a right approach.
I think this is a bit clearer? i hope it is

Edited by CakeSpear

 
n/a

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1971

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
30th December, 2009 at 18:16:08 -

Ah, so you want to scale A and B by a common factor maybe?

I think this should work:

A = A / Min(((Abs(A) + Abs(B)) / 6), 1)
B = B / Min(((Abs(A) + Abs(B)) / 6), 1)

Edited by Sketchy

 
n/a

CakeSpear



Registered
  28/01/2004
Points
  112
30th December, 2009 at 18:35:47 -

Can't say anything for sure. But this definitely looks like its going to get me somewhere, amazing!
Ill post back on how it worked out, and thanks

 
n/a

Dr. James MD

Addict

Registered
  08/12/2003
Points
  11941

First GOTW AwardSecond GOTW AwardThird GOTW AwardPicture Me This -Round 26- Winner!
30th December, 2009 at 19:47:55 -

If it doesn't work you could always add an extra event right after "Abs( A )+ Abs( B )", compare 2 values;

Abs( A )+ Abs( B ) is greater than 6; set (whatever value/thing its affecting) to 6.

 
Image
http://uk.youtube.com/watch?v=j--8iXVv2_U
On the sixth day God created Manchester
"You gotta get that sand out your vaj!" x13
www.bossbaddie.com

Muz



Registered
  14/02/2002
Points
  6499

VIP MemberI'm on a BoatI am an April FoolHonored Admin Alumnus
30th December, 2009 at 20:12:17 -

Well, if that's your exact scenario, maybe do the classic Pythagoras theorem?
Speed = Sqrt( A^2 + B^2)

You get a positive number every time, and the player doesn't go twice as fast by moving diagonally.


What James or Sketchy said should work nicely, though.

 
Disclaimer: Any sarcasm in my posts will not be mentioned as that would ruin the purpose. It is assumed that the reader is intelligent enough to tell the difference between what is sarcasm and what is not.

Image

Cecilectomy

noPE

Registered
  19/03/2005
Points
  305

Has Donated, Thank You!VIP MemberWeekly Picture Me This Winner!Cardboard BoxGhostbuster!Pokemon Ball!ComputerBox RedSanta HatSnowman
I am an April Fool
30th December, 2009 at 20:27:04 -

no muz but it still goes faster. as it should. i dont understand why it would need to be limited. this problems logic is, er, illogical.

i dont exactly get your logic? if you have a horizontal speed and vertical speed (speed by the way cannot be negative, you are thinking of velocity) logically when you add them together with vector math you ARE going to be going faster. why are you trying to make it slower? what exactly are you trying to accomplish, in real world terms please.

 
n/a

Hernan



Registered
  04/03/2003
Points
  707

VIP Member
30th December, 2009 at 20:45:02 -

I agree. This problem is kind of odd. If you're trying to do some kind of 360° movement, you should use polar coordinates (use 2 variables: speed and angle) and then convert back to cartesian coordinates (x and y speed).

(edit: typo)

Edited by Hernan

 
This space is for rent

Assault Andy

Administrator
I make other people create vaporware

Registered
  29/07/2002
Points
  5686

Game of the Week WinnerVIP Member360 OwnerGOTM JUNE - 2009 - WINNER!GOTM FEB - 2010 - WINNER!	I donated an open source project
31st December, 2009 at 00:54:10 -

He's probably trying to combine them into one event for the 20 event compo.

 
Creator of Faerie Solitaire:
http://www.create-games.com/download.asp?id=7792
Also creator of ZDay20 and Dungeon Dash.
http://www.Jigxor.com
http://twitter.com/JigxorAndy
   

Post Reply



 



Advertisement

Worth A Click