countdown timer press button (perfect, good, bad) DDR style

digitalzerodigitalzero Member, BASIC Posts: 639

so once again im back with one of my fabulous questions... i have a mini game that im creating that has buttons that you have to press before a timer goes out... the timer is going to be for each specific icon... for instance i have a left right a and b button... its going to be ddr style but instead of the arrows hitting something and having to press the direct button the icons will spawn around the scene... NOW TO THE QUESTION...

i have no idea how to do this but this is what im thinking...

first i want each icon to have its own timer within a random number... for instance it would look something like this... change attribute self.timer to random (0.5,1.5)

next i have to determine if they pressed the button fast enough!

so for simplistic reasons lets say the random number ends up being 1...

if its perfect the you would have hit the corresponding button between 1 and .5 (saying that the counter is going down)

BAM thats a perfect score

however if its between .4 and .1 (meaning the lower half of the number) then it would give you a good

BUT HERES THE KICKER....
if its not pressed at all then its a bad score and you lose a life!

how do i do this you guys please help me out... thanks so much!

Comments

  • MoikMoik Member, PRO Posts: 257
    edited December 2015

    I don't know timers well enough to know if this would work, but I'm kind of thinking like:
    1) When you start the Score timer, have the game set a NoPressYet = True
    2) Then run a separate LoseLife timer set to start once NoPressYet = True (Attribute Condition)
    3) Have the LoseLife timer use the same duration attribute as the Score timer.
    4) Have a Change Attribute of Lives = Lives - 1 set to fire after the separate LoseLife timer ends.
    5) Then have a NoPressYet = False added into the DDR Button to fire right away, before the Score mechanics trigger, to stop it from taking away the life.
    6) Then when you start a new Score timer on the button, have it also set NoPress = True again to restart the LoseLife timer.

    I'm assuming that once the attribute changes it will revert the NoPressYet action. But it may go like a Fire and Forget missile and still do it anyways after the time.

  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922
    edited December 2015

    You can capture the time. Just make two REAL self attributes time.start and time.pressed. Capture the start time when the button is in play and the time when pressed and the compare the two. We will also use your self.timer attribute which needs to be a real att as well.

    If time starts when object spawns

    Change attribute self. time.start to self.time

    Rule

    When touch is pressed

    Change attribute self.time.pressed to self.time

    Rule

    When self.time.pressed is > 0

    Rule inside above rule

    When self.start.time-self.time.pressed =< self.timer (this will detect if the touch was in time)

    To detect if past just change the operator of the condition above to >
    You will also need to control how many decimal places you monitor as real attributes will look at like eight places so 0.00000000. In order to do your rating you will need to use the abs function.

    So abs(self.time,2)-abs(self.time.pressed,2) you'll need to select numeric expression from the rule condition options.

    I'm not at my machine but will see if I can wip up a sample later.

  • SocksSocks London, UK.Member Posts: 12,822
    edited December 2015

    @digitalzero said:
    . . . the icons will spawn around the scene... ...
    . . . next i have to determine if they pressed the button fast enough!

    I'm guessing that as soon as they appear you need to press them ? There's probably dozens of ways of doing this, this is what I'd do.

    Change attribute X to random (0.5,1.5)**

    If self.time >X
    --Then 'BAD'
    Otherwise
    --If touch is pressed
    ----If self.time > X/2
    ------Then 'GOOD'
    ------Otherwise
    --------Then 'PERFECT'

    . . . . . . . . . .

    **The random function returns a whole number, so random (0.5,1.5) won't work, you would need to say: random (5,15)/15

  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922

    @Socks said:
    **The random function returns a whole number, so random (0.5,1.5) won't work, you would need to say: random (5,15)/15

    Oh yes I forgot about that.

  • digitalzerodigitalzero Member, BASIC Posts: 639

    YOU GUYS ARE AMAZEBALLS!!!

  • digitalzerodigitalzero Member, BASIC Posts: 639

    so @socks the X that you have placed is the self attribute right? the one that is the random number? so the self.time > self.timer?

  • digitalzerodigitalzero Member, BASIC Posts: 639

    nevermind got it lol

  • digitalzerodigitalzero Member, BASIC Posts: 639

    okay actually i do have a question... how do i do the math for changing the random number... lets say i want to make it inbetween 1 and 3 seconds?

  • SocksSocks London, UK.Member Posts: 12,822

    @digitalzero said:
    so @socks the X that you have placed is the self attribute right?

    X is an attribute you create for the actor.

    @digitalzero said:
    the one that is the random number?

    X is changed to a random value using a Change Attribute behaviour.

    @digitalzero said:
    so the self.time > self.timer?

    Self.time is a default attribute present in every actor.

  • SocksSocks London, UK.Member Posts: 12,822

    @digitalzero said:
    okay actually i do have a question... how do i do the math for changing the random number... lets say i want to make it inbetween 1 and 3 seconds?

    What does 'inbetween' 1 and 3 seconds mean ?

  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,880

    I assume that means any real number between 1.00 and 3.00.

    You might try something like:
    random (100,300)/100

  • digitalzerodigitalzero Member, BASIC Posts: 639

    Thanks so much you guys!

  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,880

    You are welcome!

Sign In or Register to comment.