How do I add a score based extra life?

JayReiterJayReiter TexasMember Posts: 88

I would have thought this to be simple, but for some reason I just can't figure out how to do this. I simply want my game to add an extra life for every 1,000 points the player scores. I have an integer attribute called "score," and another integer attribute called "player lives." I have an actor for the score and an actor for the lives. Each actor is linked with its relevant attribute. The lives go down when the player's health = 0, and the score goes up every time the player kills an enemy -- just like its supposed to. I added a rule to the player life actor - <img src="http://i24.photobucket.com/albums/c7/jayreiter/Screenshot39.png" border="0" alt=" photo Screenshot39.png"/></a>"">photo Screenshot39.png

I've tried game.score1000, game.score+1000, and just 1000 in the attribute rule. None of them work. The only result I've gotten of any sort was with the game.score+1000 rule, which gave the player an extra life once the first scene loaded, which I don't want, yet it wouldn't add a life when the score hit 1,000. What gives?

Comments

  • JayReiterJayReiter TexasMember Posts: 88

    Please ignore the a rel="nofollow" href="""> thing after my statement of " I added a rule to the player life actor." That code was just the beginning of the image link that I posted. It's not a part of any rule in my game code.

  • 3DMA3DMA Member, PRO Posts: 162

    Hey.
    The just 1000 solution was ok. now you need to tell the actor WHEN it is supposed to check this. You want it at the end of a round or when it really gets 1000 points and then add in real time a level?

    I´ll have to check it in game salad, but out of my head i would guess the rule will be in the actor that actually adds the points to your attribute:

    rule if ANY
    game.score=1000
    game.score=2000
    game.score=3000
    game.score=4000
    ...
    and so on

    DO:
    change attribute game.player.level to game.player.level+1

    I´m pretty sure there is a nicer solution, but as i said, that´s a quick shot out of my head.

    I hope this helps.

  • Spalding004Spalding004 Member, BASIC Posts: 89
    edited July 2014

    Set up an actor hidden in your scene somewhere that keeps track of the thousands in your score in an attribute. For instance, like this:

    change attribute: game.thousands to ((game.score/1000)%10)

    in a new rule (in the same actor)

    have this:

    When NUMERICAL EXPRESSION
    game.thousands ≠ ((game.score/1000)%10)
    DO
    change attribute lives to lives +1
    change attribute: game.thousands to ((game.score/1000)%10)

    What this does, reading from top to bottom in the actor is:
    First, when the scene is loaded it establishes a starting position for your score that it can then base awarding lives on.
    Then, it checks to see if the new count of thousands is different than the original.
    If it is, then it awards a free life and then re-establishes the baseline.

    The % sign stands for the mod or modulo function, which returns the remainder when a number is divided by another. This is the same method that is used to make custom score counters with graphical fonts.

    Using this method, you can have the player earn points in things other than a multiple of ten and it should always catch when the threshold is reached and award lives correctly.

  • JayReiterJayReiter TexasMember Posts: 88

    @3DMA said:
    Hey.
    The just 1000 solution was ok. now you need to tell the actor WHEN it is supposed to check this. You want it at the end of a round or when it really gets 1000 points and then add in real time a level?

    I´ll have to check it in game salad, but out of my head i would guess the rule will be in the actor that actually adds the points to your attribute:

    rule if ANY
    game.score=1000
    game.score=2000
    game.score=3000
    game.score=4000
    ...
    and so on

    DO:
    change attribute game.player.level to game.player.level+1

    I´m pretty sure there is a nicer solution, but as i said, that´s a quick shot out of my head.

    I hope this helps.

    I appreciate the attempt, but no that didn't solve the problem, unfortunately.

  • JayReiterJayReiter TexasMember Posts: 88
    edited July 2014

    @Spalding004 said:
    Set up an actor hidden in your scene somewhere that keeps track of the thousands in your score in an attribute. For instance, like this:

    I tried your method, but it doesn't quite work. What it does is award me an extra life from the first enemy I kill, regardless of how many points the enemy is worth. It then will no longer award me any lives at all thereafter. I'm not sure what I'm doing wrong. Here's my code:
    photo Screenshot40.png

    I added a new integer game attribute called Game Thousands (you'll see it on the left side of the screen shot highlighted in blue) and linked that into the code. I'm rather new at Gamesalad and this is the first game I've ever made, so please be very descriptive and precise with instructions. Thank you!

  • JayReiterJayReiter TexasMember Posts: 88

    I also tried turning off the first "change attribute," launched the game, and then went back in, turned it back on, and turned the last "change attribute" off and tried the game. None of the three ways worked (both on, top one off, bottom one off). I wasn't sure if you were telling me to add another "change attribute" into the rule per your instructions or not.

  • JayReiterJayReiter TexasMember Posts: 88
    edited July 2014

    I also watched @tshirtbooth2 's Scorekeeping part 3 video a few times to try and wrap my brain around his method. I couldn't find a way to apply it to this problem. I think this is what you meant when you said, "This is the same method that is used to make custom score counters with graphical fonts."

Sign In or Register to comment.