HELP with counting number of lives (finished)

Mathiashelseth99Mathiashelseth99 Member Posts: 37
edited July 2013 in Working with GS (Mac)
Help me please! I am struggling, beacause i have added lives to my game, so when the actor is hitting the wall he is losing 1 life (he has 3) but when i hit the wall and he is hitting it too fast he looses all his tree lives! is it possible to make it so you have to wait 3 seconds before he can lose more lives??????? Thanks in advice ;)

Comments

  • jamie_cjamie_c ImagineLabs.rocks Member, PRO Posts: 5,772
  • Mathiashelseth99Mathiashelseth99 Member Posts: 37
    But where should i place the timer? (which Actor) i have a life actor a player actor and the wall actor?!
  • jamie_cjamie_c ImagineLabs.rocks Member, PRO Posts: 5,772
    I can't say, I'd need to see your code. If it were me I'd set up my player to keep track of it's own lives so I'd add the time to my player, but without seeing your actual behaviors I can't really say. Post a screen shot?

    On a side note consider taking your time and learning the basics of GS before diving into a serious project.
  • Mathiashelseth99Mathiashelseth99 Member Posts: 37
    ok, beacause this is a very advanced project i am making and i am only 13 years old. i think i will put out a screen shot, when i find out what i have to lay out for you ;) please wait 5 minutes ;)
  • Mathiashelseth99Mathiashelseth99 Member Posts: 37
    edited July 2013
    {{Edited}}
  • FajlajpFajlajp Member Posts: 666
    Do you have a rule like this in your player-actor

    When player overlaps and collide with walls
    Change attribute game.lives to game.lives-1


    Because it would be a easy fix. You need to add a new behavior and a new condition in the rule+a new self.attribute(boleean) and call it "wait?" And set it to false

    The rule you had before should look like this now

    When player overlaps and collide with walls... If attribute self.wait? Is false
    Change attribute game.lives to game.lives-1
    Timer: For 3 seconds(check the run to completion) and add to the timer
    Change attribute self.wait? to true

    Hope this work because I have not tried it but it should work

    //Fajlajp
  • jonmulcahyjonmulcahy Member, Sous Chef Posts: 10,408
    you need to host it somewhere.

    but the basic idea is:

    create a local boolean attribute called 'hitWall' or something
    then have a rule that says:
    if actor overlaps or collides with actor of type wall AND self.hitWall is false
    timer after .1 seconds (run to completion enabled)
    change attribute lives to lives-1
    change attribute hitWall to true

    then another rule that says

    when self.hitWall is true
    timer after 3 seconds
    change attribute self.hitWall to false


    that should do what you want. Might be a better way, but this is off the top of my head
  • Mathiashelseth99Mathiashelseth99 Member Posts: 37
    Thanks i will try it out right now ;) i will message back here, when i am finished! Thank you ;)
  • Mathiashelseth99Mathiashelseth99 Member Posts: 37
    I
    Do you have a rule like this in your player-actor

    When player overlaps and collide with walls
    Change attribute game.lives to game.lives-1


    Because it would be a easy fix. You need to add a new behavior and a new condition in the rule+a new self.attribute(boleean) and call it "wait?" And set it to false

    The rule you had before should look like this now

    When player overlaps and collide with walls... If attribute self.wait? Is false
    Change attribute game.lives to game.lives-1
    Timer: For 3 seconds(check the run to completion) and add to the timer
    Change attribute self.wait? to true

    Hope this work because I have not tried it but it should work

    //Fajlajp
    I tried your theory :) when i collide with the wall i am only losing 1 life instead of all ;) but after 3 seconds i hear my Blopp sound (That indicates that i have hit the wall) but i dont actually lose one life?! Can you please help?
  • Mathiashelseth99Mathiashelseth99 Member Posts: 37
    you need to host it somewhere.

    but the basic idea is:

    create a local boolean attribute called 'hitWall' or something
    then have a rule that says:
    if actor overlaps or collides with actor of type wall AND self.hitWall is false
    timer after .1 seconds (run to completion enabled)
    change attribute lives to lives-1
    change attribute hitWall to true

    then another rule that says

    when self.hitWall is true
    timer after 3 seconds
    change attribute self.hitWall to false


    that should do what you want. Might be a better way, but this is off the top of my head
    Man! Thanks it really did work ;) Thanks to you and Fajlajp For helping me out ;)
Sign In or Register to comment.