What do all of the functions do?

jckmcgrawjckmcgraw Member Posts: 647
edited January 2012 in Working with GS (Mac)
Hello everyone,

I have figured out what some of the functions do through watching tutorial videos, but I have only figured out like three...

I have the random, precision, and vectortoangle functions down, and that is it.

Any help with any of the others would be greatly appreciated!
Jack McGraw

Comments

  • AsymptoteellAsymptoteell Member Posts: 1,362
    min(x,y) picks the smaller number X or Y
    max(x,y) picks the larger one.
    abs(x) absolute value
    acos(x) is (I'm pretty sure) arcos(x), so the angle whose cos is X, if that makes any sense. atan() and asin() are the same, but for tan and sin.
    Ceil(x) rounds up to the nearest integer
    floor(x) rounds down
    I'm not sure on exp(x), but I think it's e^x.
    ln(x) natural log of x, so log base "e"
    log10(x) is a normal log, with base 10.
    Magnitude is involved with distance. It's done like this distance between points (x,y) and (w,z) is magnitude(x-w,y-z)
    PadInt and PadReal are involved with displaying numbers. I haven't used them, but it's something like Padint(x,y) is x with however many zeros before it to make y digits, PadReal(x,y,z) is something about x as the number with y digits, I think, and z determines x's placement (10s, 1s, 1000ths, etc) in the number.
    pow(x,y) is x to the power of y.
    sqrt(x) is the square root.
    And you know vector to angle, but it works in the same format as magnitude, but is used to find the angle between two points.

    Hope that helps, and if I'm wrong on one, someone please correct me.

    Asymptoteell
  • CloudsClouds Member Posts: 1,599
    edited January 2012
    Excellent, not that I understand any of it, but it's a start.

    There really needs to be a good an in-depth explanation of these functions for us non-mathematicians, GS is aimed at non-programmers, which is great if you are an artist, designer or games enthusiast rather than a coder, but it seems odd to leave all these things undocumented (in relation to their use in Gamesalad) especially considering GS's intended audience.

    I would pay good money for a book that explains what these functions are and how to use them, the same goes for a lot of GS functionality, I know there is the cook book and the unofficial guide, but neither are exhaustive, the cook book doesn't even mention a lot of the functinloty in GS.

    . . . . (cont)


  • CloudsClouds Member Posts: 1,599
    . . . (cont)

    Q: The 'min (x,y)' function, how would you use this and what would you use it for ?

    Q: The 'vectortoangle' function looks useful, I see it a lot in templates and examples, if only I knew what it did (lol), like many of the clever tricks this seems off limits to most users without a guide, again the same question: how would you use it and what would you use it for . . . . . ?


    Any input greatly appreciated !


    (Ty) x (na) = (n)


  • MotherHooseMotherHoose Member Posts: 2,456
    think we can talk mynameisace into having a webinar on this???

    @Asymptoteell that is the best set of definitions, to date!
    @Tynan got vector to angle … can use … darned if I could explain it adequately!

    MH
  • CloudsClouds Member Posts: 1,599
    @ MotherHoose

    "got vector to angle … can use … darned if I could explain it adequately!"

    You maths elites, keeping all the good stuff for yourselves while we, the masses, fight amongst ourselves over a 'constrain to X' behaviour and 'change image size'.

    We will rise up one day.

    [goes back to working on his epic 'Pong™' game].
  • JohnPapiomitisJohnPapiomitis Member Posts: 6,256
    edited January 2012
    for vector to angle it will give you the angle between 2 positions as stated above. So for an example you did vectorToAngle( mouse.position.x-self.position.x,mouse.position.y-self.position.y.) And you have the actor in the middle of the scene and your mouse in the top right corner, per say itll draw a imaginary line going from the actor is in the middle to where your mouse is at the top right. So now if you constrained the actors rotation to that vectorToAngle expression, it will always face where the mouse is. To elaborate more if you had the actor have a move behavior, and had that vectorToAngle expression in its direction value, it will move at that exact angle across that imaginary line to where the mouse is.

    Now for the min and max, you could put those 2 together in a constrain expression and give it the minimum position and the maximum position it can be in, and the actor will not go pass those set boundaries.

    Heres an example (credit goes to tsb, he has this demo and expression on gshelper.com);

    When touch is pressed, constrain self position x to: max((0+( self.Size.Width /2)),min((320-( self.Size.Width /2)), game.Mouse.Position.X ))

    What that will do is when you touch the actor you can drag it around on the x axis, but it will not leave the screen (for portrait) because the begining of the scene is 0, and the end of the screen is 320. If you swapped out the 320 for 480, it will keep it inside the screen limits of a landscape screen, because the end of the landscape screen is 480.

    You can also use min and max in a constrain for say a volume slider, where you would want to slide it around to set the volume, but not be able to drag it past the limits of the slider.

    Hope that wasnt confused and helped explain a little bit, im half asleep but just wanted to try and help before i went off to bed.

    cheers

  • jckmcgrawjckmcgraw Member Posts: 647
    Thank you so much everybody for the help! I will keep this thread handy.

    @tynan I wouldn't consider myself part of "the masses". It's just that I haven't learned any of this stuff yet (I'm in 8th grade geomotry right now). I would agree that GS needs more tutorials on it though.
  • CloudsClouds Member Posts: 1,599
    edited January 2012
    @ jckmcgraw

    "I wouldn't consider myself part of "the masses"

    My comment was a joke.

    "I would agree that GS needs more tutorials on it though."

    Yes, definitely, a tutorial on each function would be ideal, with illustrations too (and maybe a song?).

    : )
  • CloudsClouds Member Posts: 1,599
    @ JohnPapiomitis

    Thanks for the explanation, I will take another read tonight and then play around with those two functions to see if I can get my head around them.

    Much appreciated !
  • BBEnkBBEnk Member Posts: 1,764
    There used to be a support page to all of those on the forms with examples but I don't see it anymore it was very helpful.
  • AsymptoteellAsymptoteell Member Posts: 1,362
    A song, you say?

    Hush, little one... Don't make a sound.
    Ceil(x) rounds up... Floor(x) rounds down.

    Hush, little one... Don't say a word.
    cosines sines and tangents are a bit absurd...

    Sleep, Little one... Close your sleepy eyes.
    Min and max can give actors constraints. What a surprise!

    Rest, Little one... Lay down your sleepy head.
    Magnitude's for distance. Pop POP! Magnitude said.

    Good night, Little one... This song is almost done.
    Vector to angle tells the angle between; oh what fun!


    Lullabies are the only way.

    Asymptoteell
  • CloudsClouds Member Posts: 1,599
    @ Asymptoteell

    : )

    Ha!

    "cosines sines and tangents are a bit absurd..."

    Funnily enough cosines and sines are the only ones I do understand and know how to use !


  • jckmcgrawjckmcgraw Member Posts: 647
    @asymptoteell Ha. Awesome!!
Sign In or Register to comment.