Type of Counter

KempProductionsKempProductions Member Posts: 139
edited November -1 in Working with GS (Mac)
Ok, im trying to create a game where you have to destroy a certain number of blocks, without letting an item at the top of the stacked blocks, hit the ground. I've figured a lot of it out, but I don't know how to add a counter to keep up with how many blocks you have left to destroy. Can anyone help me??

Comments

  • JGary321JGary321 Member Posts: 1,246
    Sure,

    You need a game.attribute named 'Blocks Left'

    Under the rule that 'destroys' the block add a Change Attribute:

    game.Blocks Left = game.Blocks Left -1
  • firemaplegamesfiremaplegames Member Posts: 3,211
    Sounds sort of like my game, Danger Cats!...

    You need to keep a global game attribute (integer) called "blockCount". When the level starts, set it to the appropriate amount.

    Every time you remove a block, use a Change Attribute behavior to set it like this:

    Change Attribute:
    game.blockCount To: game.blockCount -1

    Hope this helps!
    Joe
  • WeswogWeswog Member Posts: 1,171
    You make an integer attribute called for example counter put however many blocks you have in the game and put it in the attribute then go to your block actor and have it

    Touch is Pressed
    Destroy this actor
    Change Attributee counter-1
    Then when attribute counter less than or equal to 0

    Cheers, Weswog

    EDIT:Sorry I was writing on this post and FMG Wrote before me
  • JGary321JGary321 Member Posts: 1,246
    First!

    Crazy how we all compete to be first to answer the easy ones =)
  • KempProductionsKempProductions Member Posts: 139
    Ok im just messing around trying to figure it out right now. I added an integer game attribute named 'blockCount' and put the value 1. Then i have an actor called 'block' and another actor called 'blockcounter'. For the block i added a rule, and set it to touch and destroy. then in the same rule i set a change attribute to what yall told me to. What do i do to the 'blockcounter' actor? Or am i doing this all wrong.
  • KempProductionsKempProductions Member Posts: 139
    Nevermind. I figured it out! Thank all of you for the help! I will probably be back for more :P
  • KempProductionsKempProductions Member Posts: 139
    More questions! Haha.

    -I figured out how to display text such as "congrats" when the 'blockcounter' equals 0 and the item has not touched the ground. And i was able to figure out how to reset the level when the item touches the ground. But i cant figure out how to display text in the middle of the screen that says something like "sorry, or fail" when this happens, and how to reset the 'blockcounter' to its orginal value when the scene resets.
  • KempProductionsKempProductions Member Posts: 139
    Anybody?? :/
  • scitunesscitunes Member, Sous Chef Posts: 4,047
    Create a boolean game attribute called lose. Then have a rule in the actor that can't fall that say's when collides with ground change attribute game.lose to 1.

    Then in the text actor have a rule that says when game.lose is true display text "better luck next time!"
  • KempProductionsKempProductions Member Posts: 139
    Ok, i got it to say loser in the right spot, but when it resets the scene, the 'blockcounter' number doesn't reset and "loser" stays on the screen.
  • JGary321JGary321 Member Posts: 1,246
    Hey Kemp, whatever triggers "loser" & right before the reset ( i mean literally right before, like 1 sec before) make a rule that says

    Change game.blockcounter to 0 (or whatever the starting point should be)

    This is how I like to do it. I do this to reset my HP when you lose.

    When HP = 0 Spawn actor "Mission Failed"

    The "Mission Failed" actor is a graphic file that says "Mission Failed".
    In that actor I have

    Timer: After 2 secs change game.HP to 20. (check completion box)
    Timer: After 3 secs change scene. (check completion box)

    Hope this helps.
  • KempProductionsKempProductions Member Posts: 139
    Thank you guys! I got it to work, not the way I would have liked it. But good enough.

    Then, I realized, that due to the 'blockCounter' being a Game Attribute, the number has to be the same throughout the game. Which is not what I would like. If there is a way to change this number throughout the game, please tell me. Otherwise, I wont be able to make my game.
  • EastboundEastbound Member, BASIC Posts: 1,074
    When you double click on an actor in a scene, you can edit that specific instance. Now if you make changes to that actor in the actor tab, it won't change that specific one in the scene because you edited it. You can press the 'revert to prototype' button to reset it back to the parent actor if you want.

    Now you could just add a controller object that sets the blockCounter attribute for each specific scene.
Sign In or Register to comment.