Question for Orbz: How can I create an exponential expression?

SaveDaveSaveDave Member Posts: 140
edited November -1 in Working with GS (Mac)
How can i create an exponential expression..??

what im looking to do is for a score to increase as you get closer to the end of a level:

i.e. starts off on zero and in effect, accelerates up to 100,000. i need this on an increasing level if this all makes sense!

help would be really appreciated!!

EDIT by BeyondtheTech: I know our forum doesn't really have private messaging, except for writing on developer's "walls," but please refrain from creating vague topic titles such as "question for xxx," especially if others can be helpful to chime in, and if others have similar issues and need to search through the titles to see if it has been discussed before. I have therefore renamed the title according to your actual message.

Comments

  • RHRH Member Posts: 1,079
    Can't you just do something like, 1.1^score.

    It's hard to tell you what figures to use as I don't know what your score is based on (is it distance/enemies kiled?) or what the limit is.
  • ORBZORBZ Member Posts: 1,304
    Assuming the level is left right on the x axis you can subtract the difference between the player position X and the goal position X. Then raise that to some power. I'm not sure if that's what you are looking for though.
  • SaveDaveSaveDave Member Posts: 140
    think of it as a doodle jump with an end. the closer to the end you get the greater your score will be.

    So... it will increase rapidly the closer you get to the goal.
  • ORBZORBZ Member Posts: 1,304
    Ahh gotcha, k, let me think. I just woke up :)
  • RHRH Member Posts: 1,079
    How large is the scene? Height wise.
  • SaveDaveSaveDave Member Posts: 140
    5500 pixels

    standard width.
  • RHRH Member Posts: 1,079
    If you do this:

    `constrain attribute game.score to exp(self.position.X/477.72393009357)`

    that will give you exactly 100,000 when the characters position is 5500. You could just use 477.7 which would give you 100,057 when the characters position is 5500 which is not only easier but I assume you want the end to be slightly before the top of your scene? Or even just 477, which ever suits you game best.

    By the way, exp(x) is the same as e^x.

    If you didn't want to use e as the constant you could just use something like

    `constrain attribute game.score to 1.0021^self.position.X`
  • ORBZORBZ Member Posts: 1,304
    (TotalDistance - currentPosition)^2
  • SaveDaveSaveDave Member Posts: 140
    thanks guy!

    great help...

    if all goes well i should have a wicked game finished with the next week or so!!
  • RHRH Member Posts: 1,079
    By the way, if you used mine, I meant self.position.Y where I put self.position.X
  • ORBZORBZ Member Posts: 1,304
    Oops

    Position/totalDistance*maxScore
  • SaveDaveSaveDave Member Posts: 140
    okay... i think this is making sense.. so i set the "game score" actor to have this constrained attribute? is that correct?

    also, how would i then go about stopping the score from continuing to increase once the screen is touched for example?

    ??
  • ORBZORBZ Member Posts: 1,304
    also, how would i then go about stopping the score from continuing to increase once the screen is touched for example?

    You need to set a global boolean variable called "touched" and when the screen is touched set it to true. then put the score computation inside a rule that says when game.touched = false
Sign In or Register to comment.