HELP! POWER UPS !

Lu_merlinLu_merlin Member Posts: 45
edited November -1 in Working with GS (Mac)
Hello Everyone!
I have been using gamesalad since 4 days now and I LOVE it!
But i have a problem: I created a 2d shooter game and it has a few power ups. I know I can spawn an actor with a timer and so on but i would like to spawn the power up every time the player hits a thousand points.(1000,2000,3000...)
I don't know how to do it!
Please Help!!!

-Lu_merlin

Comments

  • RiffelRiffel Member Posts: 1,272
    create a rule for each power up:
    if scores >= 1000 spaw power up 1

    if scores >= 2000 spaw power up 2

    ..

    ..
  • Lu_merlinLu_merlin Member Posts: 45
    I am not sure if i quite get that!

    1. I have a spawner.
    2.That would only work once for 1000 and then 2000?
  • Lu_merlinLu_merlin Member Posts: 45
    Ok but then i would have to do that for ever!
    And What if i want it to go to 70.000 ?
    Do i Have to do it 70 times ? Is there no different way?
    Thx for the quick responses!
  • firemaplegamesfiremaplegames Member Posts: 3,211
    To do that, you should use the 'modulus' operator, which is the percent sign: '%'.

    Here's how:

    In the spawner actor, create an integer attribute called something like "powerUpScore".

    Then use a Constrain Attribute and a Rule, like this:

    Constrain Attribute
    self.powerUpScore To: game.score%1000

    Rule
    when all conditions are valid:
    self.powerUpScore >= 1000
    -----Spawn Actor: [your power up]

    That will spawn a power up every 1000 points, regardless of the score.
  • RiffelRiffel Member Posts: 1,272
    firemaplegames said:
    To do that, you should use the 'modulus' operator, which is the percent sign: '%'.

    yep, some times you need use some tricks like the module one.
  • Lu_merlinLu_merlin Member Posts: 45
    Yeah i thought exactly the same but couldn't find the modulus operater!
    Thanks for your help !!!
  • Lu_merlinLu_merlin Member Posts: 45
    firemaplegames said:

    Here's how:

    In the spawner actor, create an integer attribute called something like "powerUpScore".

    Then use a Constrain Attribute and a Rule, like this:

    Constrain Attribute
    self.powerUpScore To: game.score%1000

    Rule
    when all conditions are valid:
    self.powerUpScore >= 1000
    -----Spawn Actor: [your power up]

    That will spawn a power up every 1000 points, regardless of the score.

    Hello,
    I tried to do what you said but it didn't work out.
    I just have 2 questions:

    -Shouldn't the powerupscore be a real attribute instead of an integer attribute ?
    the modulus isn't an integer most of the time is it ?
    -And why idid you write >= 1000 in the rule?
    Shouldn't it be 0? i.e., modulus Gamescore/1000 = 0 ?

    I also tried to display the powerupscore with your syntax to debug the code but it stayed 0.

    Any help would be much appreciated!
  • firemaplegamesfiremaplegames Member Posts: 3,211
    Oops! Sorry about that. You are correct...

    It should be:

    Constrain Attribute
    self.powerUpScore To: game.score%1000

    Rule
    when all conditions are valid:
    self.powerUpScore = 0
    -----Spawn Actor: [your power up]

    Modulus just shows the remainder after division. I would leave it as an integer. Unless your score has decimal places?

    i.e:

    1007%1000 = 7

    1005.6%1000 = 5.6
  • Rob2Rob2 Member Posts: 2,402
    need to add a condition to stop the first power up at 0?
  • firemaplegamesfiremaplegames Member Posts: 3,211
    Oops. Yeah. I should really test things out before I write!
    Or get some more sleep, either one!

    When you create the powerUpScore attribute, initialize it to be 1 instead of 0.

    Or put in a condition like rob2 says.
Sign In or Register to comment.