Increase Gravity at Set Intervals

Bolt2Bolt2 Member Posts: 41
edited April 2012 in Working with GS (Mac)
Greetings GS Forum!

I am currently trying to add a rule that:

-On achieving 20 Points
-Gravity Increases +50
-On going below 20 points
-Gravity Decreases -50

This is simple enough. However, I want it to be in multiples of 20. So:

-On achieving 40, 60, 80, 100 Points (etc).
-Gravity increases +50 at these intervals
-On going below 40, 60, 80, 100 Points (etc).
-Gravity Decreases -50 at these intervals.

Any suggestions?

-Thanks

-Blackmill

Best Answer

  • GreekSaladGreekSalad Posts: 36
    Accepted Answer
    You'll want to create some attributes to reflect all of these updates

    And it should look a little something like this:

    game.NextLevel = 20 (This is going to be a representation of the Goal you're aiming for. You can set this to be any number you want)
    game.CurrentPoints = 0 (This is the amount of points that your player has gained so far)
    game.Interval = 20 (This is the interval you want to change between points that adjust the gravity. You can set this to be any number you want)


    When game.CurrentPoints ≥ game.NextLevel

    Change Attribute:
    Increment game.NextLevel+game.Interval
    game.Gravity +50


    So then, what will happen is, you'll find that your game.NextLevel will be 40,60,80.. etc. - This is kind of a general look at using intervals and adjusting other attributes accordingly.

    Hope this is of some help to ya. :)

Answers

  • simo103simo103 Member, PRO Posts: 1,331
    edited April 2012
    If NewPoints-OldPoints=20 then Gravity=Gravity+50

    otherwise
    if NewPoints-OldPoints=-20 the Gravity=Gravity-50

    I think? Not quite ... thinking some more .......
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    edited April 2012
    Just dreamt this up... it's untested but I think it may do the trick.

    You would need two game attributes, something like game.nextscore and game.currentscore. Just before you change (increase or decrease) the score, change attribute game.nextscore to game.currentscore plus or minus the amount.

    Then, have a rule that checks to see if floor(game.nextscore/20) is greater than floor(game.currentscore/20). If so, you've passed a 20 point marker while increasing your score. Also check to see if floor(game.nextscore/20) is less than floor(game.currentscore/20). If so, you've passed a 20 point marker while decreasing your score.

    The difference between those two "floor" values could be used to determine the new gravity as follows: change attribute game.gravity (or however you are doing gravity) to game.gravity+(floor(game.nextscore/20)-floor(game.currentscore/20))*50.

    This is all off of the top of my head... let me know if it works! :)

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • Bolt2Bolt2 Member Posts: 41
    @simo103 No, not quite.
    It's a tricky one.

    -Blackmill
  • Bolt2Bolt2 Member Posts: 41


    game.NextLevel = 20 (This is going to be a representation of the Goal you're aiming for. You can set this to be any number you want)
    game.CurrentPoints = 0 (This is the amount of points that your player has gained so far)
    game.Interval = 20 (This is the interval you want to change between points that adjust the gravity. You can set this to be any number you want)


    When game.CurrentPoints ≥ game.NextLevel

    Change Attribute:
    Increment game.NextLevel+game.Interval
    game.Gravity +50
    If it dipped below the required number, would it then also decrease the gravity? Or would I need to add another rule?

    -Blackmill
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    I'll have a demo for you in just a sec...

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • Bolt2Bolt2 Member Posts: 41
    I'll have a demo for you in just a sec...
    Thanks

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    edited April 2012
    [Edit: forgot to move the final check rule to inside the When Touch is Pressed; see fixed version below]

    Hmm... works great with a score increment of 3, but not with higher numbers. Well, it's a start!

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

Sign In or Register to comment.