How to display a count down clock that starts from a random number?

I'm trying to make a clock that count down by the seconds, but I want it to pick a random number out of 10sec - 30sec to start from then count down to 0.

So when I reset my game it should pick a new number each time, but no higher then 30sec and no lower then 10sec.

Comments

  • BellowBellow Bartender Member, PRO Posts: 227
    here change att where the 60 writing to number you want.

    http://speedy.sh/kGMX3/timerr.rar
  • mounted88mounted88 Member Posts: 1,113
    Try to keep up I'm not good at explaining.
    First make a game attribute (timer)

    Next make a rule-game.timer=random(1,20)

    Inside that rule add 20 more rules.

    Rule
    Game.timer=1
    Timer for 10 secs (and add what you want in the timers)

    Next rule
    Game.timer=2
    Timer for 11 secs (and add what you want in the timers)

    And so on and so on.

    That should do the trick if I get back to my computer and your still having troubles let me know and I'll do a sample for you.

    Good luck hope I didn't confuse you more then when you started.
  • BellowBellow Bartender Member, PRO Posts: 227
    yeap i read wrong i think at the first i only make timer for you mix mounted explaining and my timer together it will work.
  • ok Thank guys, I'm going to give it a try right now. I'll let you know if it works out.
  • therobinsonbros@gmail.comtherobinsonbros@gmail.com Member Posts: 34
    edited October 2013
    yeah I'm confuse Hey Mounted should my game attribute be a real or integer? I was using a real when I made my... "game.MyTimer"
  • This is what I had first, it count down from 15sec.

    Display Text:
    abs(prec(game.my timer,2))

    change attribute:
    set: game.start time to: game.time

    Rule:
    if game.my timer >0

    Do:
    constrain attribute:

    constrain: game. my timer to 15-(game.time-game.start time)
  • -Timo--Timo- Member Posts: 2,313
    Try to keep up I'm not good at explaining.
    First make a game attribute (timer)

    Next make a rule-game.timer=random(1,20)

    Inside that rule add 20 more rules.

    Rule
    Game.timer=1
    Timer for 10 secs (and add what you want in the timers)

    Next rule
    Game.timer=2
    Timer for 11 secs (and add what you want in the timers)

    And so on and so on.

    That should do the trick if I get back to my computer and your still having troubles let me know and I'll do a sample for you.

    Good luck hope I didn't confuse you more then when you started.
    This is really a hard way ;)
    This is how I should do it.
    First make a boolean attribute (start timer) and a integer attribute (timer)
    Rule
    If game.start timer is true AND if game.timer is 0
    Do
    Change game.timer to random(10,30)
    Interpolate game.timer to 0
    In game.timer seconds

    The attribute game.start timer is not something you really need. Its just to start the timer
    You can have a button
    If touch is pressed
    Do
    Change game.start timer to true
    And it starts the timer ;)

    I cant help you with the code abs(prec(game.my timer,2)) because I dont know what abs and prec does ;) so if someone can tell me (I though @Socks gave you this rule) would be really appreciated

    Hope this helped

  • timolapre1998 thanks I'll give that a shot right now
  • Oh my GOD it WORK! You're the BEST! I've been stuck on this for a week... thanks again!!!
  • mounted88mounted88 Member Posts: 1,113
    Well glad someone pointed you in the right direction.
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    edited October 2013
    @timolapre1998 abs is just "absolute value" which returns the positive value of a number and prec is "precision" which limits the number of decimal places.

    So if game.my timer is -3.1258699, abs(prec(game.my timer,2)) will return 3.12.

    See http://cookbook.gamesalad.com/definitions for more.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

Sign In or Register to comment.