Random Score

natclarkenatclarke Brisbane, AustraliaMember, PRO Posts: 243

I have an creature in my game that moves on and off the scene. In that actor I have it set to random images. ie. seal, shark, seahorse (self image etc)

When the hero collides with the creature, I would like it to remove points.

-1, -5, -10, -15 & -20 points?

Can it be coded depending on what creature image appears? i.e. -20 points for a shark, -1 point for a seahorse

I currently have it working with all the creatures losing -5 points and a spawn image of the points lost.

thanks

Natalie

Nat Clarke
Life Cleansing

Comments

  • pHghostpHghost London, UKMember Posts: 2,342

    How are you randomizing the images? Can you use the same method change the point modifier at the same time?

  • jeezzcakejeezzcake Member Posts: 144

    You can use a table with n rows and 2 columns ( 1st column is the image name(shark), 2nd column = points to be removes (-20) ) .

    When you randomly select a row from the table, you change the image and a self attribute (i.e. self.minusPoints ) to the values of the columns.
    [ self.image = shark, self.minusPoints = -20 ]

    When the creature collides with the hero, subtract from the main score attribute the self.minusPoints.

    I haven't tried it...

    Hope this works.

  • jamie_cjamie_c ImagineLabs.rocks Member, PRO Posts: 5,772
    edited October 2014

    If you didn't want to use tables I suppose you could also set up a series of rules that says something like this:

    Rule 1:
    
    When the Attribute self.Image contains shark
    
    Change Attribute pointValue to 10
    
    
    Rule 2:
    
    When the Attribute self.Image contains seal
    
    Change Attribute pointValue to 5
    
    etc...
    

    This assumes you have an Attribute named pointValue to keep track of how many points each actor is worth.

  • MalkovichMalkovich Member, PRO Posts: 116

    Hi @natclarke, make a game integer attribute call it "creature" for example and make it random between your number of creatures. (example 1= shark, 2=seal, 3 =seahorse). Use that attribute in a rule to change image.

    Then make a rule, when hero collides with creature AND attribute "creature" is 1 (shark), remove -20 points". Do the same for your others creatures..

    I hope that works..

    But i think more simply is to make different actors.

    Greetings

  • natclarkenatclarke Brisbane, AustraliaMember, PRO Posts: 243

    Thanks. I appreciate all the great suggestions.

    I ended up going with changing the rules as I had points images showing if the hero collided with the creature.

    I went with the easiest road!

    Rule 1:

    When the Attribute self.Image contains 1

    Change Attribute score to score -5 etc

    It works great now.

    Thanks

    Nat Clarke
    Life Cleansing

  • jamie_cjamie_c ImagineLabs.rocks Member, PRO Posts: 5,772
Sign In or Register to comment.