sin: up or down

wouterwouter Member Posts: 174
edited November -1 in Working with GS (Mac)
hi guys,

how can i check if the attribute is moving up or down (using a sinus on an attribute..)??
i can create a Boolean up thats true or false but how can i check if the attribute is going up (or not)....

wouter

Comments

  • MarkOnTheIronMarkOnTheIron Member Posts: 1,447
    Check the actor linear speed X or Y (depending on the orientation) if it's positive is going up and if it's negative is going down.

    ________________________________
    【ツ】iPhone Icon Pack 【ツ】 - 【ツ】Graphic Pack【ツ】
    Free GS demo: High score simple and advanced; Game Center; App Rating System
  • RHRH Member Posts: 1,079
    Off the top of my head, you could create another two attributes (say called test and up/down).

    Make a rule that when your attribute > self.test:

    change attribute self.up/down to 1 & change attribute self.test to your attribute

    OTHERWISE

    when attribute your attribute < self.test:

    change attribute self.up/down to 2 & change attribute self.test to your attribute

    This means that when self.up/down is 1 your attribute will be increasing and when it is 2 your attribute will be decreasing.

    Haven't tested this and the effectiveness may vary depending on how fast your attribute is changing.
  • wouterwouter Member Posts: 174
    ok thanks, will check this out;)
  • wouterwouter Member Posts: 174
    oh and with the linear speed y (in this case), can i check also the direction? (because i must make an animation of the attribute and not only up or down;) (must be smooth)

    @RH
    and this can't with you're way;) if this also can't with the linear speed, witch way is the best?
  • JohnPapiomitisJohnPapiomitis Member Posts: 6,256
    if motion linear x is > 0 your moving left

    if motion linear x is < 0 your moving right

    if motion linear y is > 0 your moving up

    if motion linear y is < 0 your moving down

    :)
  • wouterwouter Member Posts: 174
    yeah thanks, only i want to animate the sin so you get if direction is <20 animation picture 1, >20 but <40 animation picture 2 and so on... gives linear y also this direction? (or is there another way to do this?) (so the next step is that i can track the direction of the attribute)

    only another problem (maybe) is that the attribute stays on 1/3 of the screen... so you see only the background moving and the attribute moving up and down... don't know if this is a problem?

    thanks!
  • RHRH Member Posts: 1,079
    Ok, so now I'm assuming by attribute you mean actor moving up or down rather that attribute increasing/ decreasing. Coming what Mark and John have said. As for changing the image depending on Y location...

    If you name your images image1, image2, image3, etc. image1 for <20, image2 for <40 and so on.

    You can then add a constrain attribute:

    self.image -- to -- "image"..ceil(self.positionY/20)..".png"
  • wouterwouter Member Posts: 174
    mmm i'm doing something wrong...

    tried couple of things:
    made a game attribute velocity x and velocity y
    constrain attribute: game.velocity y to self.motion.lineair velocity. Y and tried to display it (display text game.velocity y), but there happened nothing (only displayed 0...)

    then i tried to make a game attribute up, and a rule:
    when attribute self.motion.therest > 0 change attribute game.up to true, otherwise game.up to false,
    only he displayed false the whole time...

    what do i wrong??

    thanks;)

    oh and RH i see what you mean (and thanks;), only i don't know how to do that with the y location... (think thats also the fault here...)
  • RHRH Member Posts: 1,079
    Ok, are you making the actor move up and down by constraining self.position.X using the sin function? If so the y velocity will be 0 I think so you won't be able to tell whether it is moving up or down using y velocity. Instead you will have to do something like what I told you above.
    wouter said:
    oh and RH i see what you mean (and thanks;), only i don't know how to do that with the y location... (think thats also the fault here...)

    And to do it with the Y location in the attribute browser just go to
  • wouterwouter Member Posts: 174
    you mean a constrain attribute to safe the current position y (self.position.y) in lets say y position;) and then check if the y position is higher or less high than in y position. ?????
    think this will work, only i need to animate the actor.... or must i use also the x location to calculate the direction?

    thanks;)
  • wouterwouter Member Posts: 174
    only this also doesn't work (change attribute game.position y to self.position.Y) because the y stays on 0.... what to do???
  • RHRH Member Posts: 1,079
    I don't really know what's going on in your project. Can you post a screenshot of the rule that you are using to move the attribute up and down using sin function?
  • wouterwouter Member Posts: 174
    the sin function?
    looks like the example: http://gamesalad.com/wiki/how_tos:gsc_wave_movement
    so i have:
    constrain attribute: game.position y to game.amplitude*cos(game.period*(self.position.X-self.InitX))+game.balance (y position where the cos or sin is moving around;)
  • wouterwouter Member Posts: 174
    anyone?...
    or can't this be done in gamesalad?...

    (edit:)
    hey i have an idea!!!!
    if i let an other actor move with the sin actor, will the position y work on that actor?:D

    [edit2]
    mmm the y position works now! i think (not sure) that its now working because i have placed it on the top (for all the rules)...
    so how can i calculate the direction?
    x1,x2,y1,y2 and then y2-y1/x2-x1 ???

    and thank you RH!!!! i was stuck on this point (is this correct english? lol)
  • RHRH Member Posts: 1,079
    I just messed around with it and to calculate the direction create a rule so that:

    When attribute game.up/down = game.balance + game.amplitude
    change attribute game.up/down to 2

    OTHERWISE

    When attribute game.up/down = game.balance - game.amplitude
    change attribute game.up/down to 1

    This means that when game.up/down = 2 game.positionY is increasing and when it = 1 it's decreasing.

    That works in my project I just tested it in so hopefully you can get it to work in yours.
  • wouterwouter Member Posts: 174
    ok thanks;)
    i let you know if it works;)
  • wouterwouter Member Posts: 174
    lool
    i tried something different (with y1 and y2):

    constrain attribute game.y1 to self position.Y

    rule: game.Y2>game.Y1{
    game.up to 0
    game.Y2 to game.Y1
    }
    otherwise{
    game.up to 1
    game.y2 to game.y1
    }

    only above the balance he says 1 and under false??!! lol do you know what my fault is? (now i am going to use you're way;)
  • wouterwouter Member Posts: 174
    mmm doesn't work!
    did exactly what you said.

    but it's logic because game.up = 0 in the beginning so:
    0 = game.balance (260)+game.amplitude(30)
    no its not... so otherwise:
    0=260-30 no its not!!

    so you mean something else what you said, or i don't get it;)
  • RHRH Member Posts: 1,079
    If you want, you can send me the project file and I'll pop it in for you because it works in my project :S rhgamesalad [@] gmail.com is my email.
  • wouterwouter Member Posts: 174
    ok thank you very much!

    i send you an email;)
  • RHRH Member Posts: 1,079
    replied, and hopefully sorted!
  • wouterwouter Member Posts: 174
    it works, thank you very much!!

    wouter
Sign In or Register to comment.