How do I change scene gravity with score?

dabbuhldabbuhl Member, PRO Posts: 52

I have a game where things drop from the top of the screen to the bottom. I have set the scene gravity to 10 so that the actors fall slowly. After a specified score, let's say 20, I want to change the scene gravity for all actors to 20 and so forth. So after the score is 50, change all gravity to 30. This will cause the actors to fall faster as the points get higher.

I'm just not sure of how to do this.

Best Answers

  • SocksSocks London, UK.Posts: 12,822
    edited November 2014 Accepted Answer

    @dabbuhl said:
    I have 27 actors. 3 different accelerate speeds. How would I change them all to increase the accelerate speed with the score?

    Use some simple maths.

    Let's say your three speeds are 50, 120 and 400.

    Change those to 50 X a multiple of the score, 120 X a multiple of the score, 400 X a multiple of the score.

  • 2create2create Posts: 90
    Accepted Answer

    The logic is following

    IF
    (numeric expression) : SCORE%10=1
    THEN
    Gravity = Gravity + GravityIncrement

    So : every 10th count of the score (use the % operator) gravity value will be added with the value specified in GravityIncrement.

    And it's better to use Accelerate behaviour instead of Gravity because it's much easier to handle and change it.

    Remove gravity from the Scene settings
    Create game.Weight variable and set its initial value
    In every actor using gravity set behaviour
    Accelerate = game.Weight

    Then update game.Weight with the exression showed at the top of the post.

    Good luck!!

    Yops – the innovative puzzle game for iOs – http://apple.co/1ESvIlC
    Other games - http://appstore.com/flashpromllc/

Answers

  • SocksSocks London, UK.Member Posts: 12,822

    Switch scene gravity off . . . . and use Accelerate (270° relative to scene) on your falling actors.

    Accelerate is a much better way to implement gravity, it's more controllable, and obviously you can link the Accelerate speed to your score.

  • dabbuhldabbuhl Member, PRO Posts: 52

    I have 27 actors. 3 different accelerate speeds. How would I change them all to increase the accelerate speed with the score?

  • colandercolander Member Posts: 1,610
    edited November 2014

    Use Constrain behaviour i.e. Constrain mySpeed To myScore / or * by something that gives you the result you are after. Hope this makes sense.

  • dabbuhldabbuhl Member, PRO Posts: 52

    @iknikitin said:
    The logic is following

    IF
    (numeric expression) : SCORE%10=1
    THEN
    Gravity = Gravity + GravityIncrement

    So : every 10th count of the score (use the % operator) gravity value will be added with the value specified in GravityIncrement.

    And it's better to use Accelerate behaviour instead of Gravity because it's much easier to handle and change it.

    Remove gravity from the Scene settings
    Create game.Weight variable and set its initial value
    In every actor using gravity set behaviour
    Accelerate = game.Weight

    Then update game.Weight with the exression showed at the top of the post.

    Good luck!!

    So, I would need to add this to every actor at the top of the actors properties?

    If my accelerate starts out at 25 and every 50 points I want to increase the acceleration by 10%, I'm not sure how to create this rule:
    Basically if score = 50
    accelerate=accelerate+10%

    Can anyone tell me how to write this out?

  • 2create2create Member, PRO Posts: 90
    edited November 2014

    Create top level vars (type: REAL) :

    game.ACCELERATION = 25 (default acceleration value)

    game.IncreaseAccelerationEvery = 50 (increase acceleration every 50 points)

    game.IncreaseAmount = 0,1 (increase by 10%)

    and of course you have game.SCORE

    Put the following rules at the top of actor

    1___________________

    IF:

    1) [numeric expression] : game.SCORE%game.IncreaseAccelerationEvery = 0

    2) [attribute] : game.SCORE > 1

    THEN:

    ChangeAttribute (game.ACCELERATION) = game.ACCELERATION+game.ACCELERATION*game.IncreaseAmount

    2___________________

    Accelerate (
    .270 degrees
    .value: game.ACCELERATION
    )

    Yops – the innovative puzzle game for iOs – http://apple.co/1ESvIlC
    Other games - http://appstore.com/flashpromllc/

Sign In or Register to comment.