Clicks Per Second

CrumbyEntertainmentCrumbyEntertainment Member, PRO Posts: 32
edited December 2013 in Working with GS (Mac)
Anyone know how we could display the number of clicks that is made in one second? We have two variables, "clicks" which registers how many clicks is made on the actor and then "CPS" which is suppose to show how many clicks per second there are.I feel like this is a very simple task I am just having a brain fart.

Comments

  • CrumbyEntertainmentCrumbyEntertainment Member, PRO Posts: 32
    Hey guys i still need help with this. if you have any ideas feel free to message us.
  • TheGabfatherTheGabfather Member Posts: 633
    edited December 2013
    Can you explain the mechanics that you had in mind?
    - Is there only 1 second allotted for clicking?
    - Is this something like, average clicks per second?

    If it's the former, the simplest way is to make use of a Timer (you can use GS' Timer, or you can make your own) and a custom Attribute to take note of clicks. Each time you click, increment the Attribute by 1 (e.g. Change Attribute: self.clicks to self.clicks + 1). After 1 second has passed, disable the Rule that increments, and voila. You can pass that value around your game however you please.

    If it's the latter, you'll probably want to store each second's number of clicks inside a table (one cell for each). Afterwards, you just calculate for the Average of all the values. Oddly enough, I can't find a stock function inside the Expression Editor, so you will have to do this manually. You will also want to reset the number of clicks that you're keeping track of to zero every time a second has passed.

    I'm still not sure how you want this to be though.
    The more info you provide, the better we can help :)
  • CrumbyEntertainmentCrumbyEntertainment Member, PRO Posts: 32
    edited December 2013
    Ok so i want something that will calculate the number of clicks and the number of clicks per second when ever i click on a particular actor. So right now i have two variables: total clicks and clicks per second. So Total Clicks is just the total amount of times that the actor has been clicked, thats it. Then for clicks per second, i want it to be able to calculate how many times that actor was clicked on in one second. I want this to be a value that changes with the more clicks there is and in theory go on forever until the scene is over.Also, i would want it to go back to 0 if the actor hasn't been clicked on in more than 2 seconds (during which time the Clicks Per Second value would be gradually decreasing.) ALSO, simply dividing the Total Clicks by the Scene time does not work or give the desired value because the number would never be 0 even after not clicking for an extended period of time. So it is not necessarily an Average amount of clicks over an extended period of time. So lets say that i click the actor 10 times in the first 1 second. The clicks per second would be 10. But then lets say i stop clicking for a second or two, the clicks per second value would go down from 10 to 9 to 8 etc...until 0.
    So i know that a timer must be involved, also probably some sort of interpolation so that the number just doesn't go from 10 to 0 during that 2 second non clicking window.
    i thought maybe that i could use a timer inside the "when actor is touched" rule and every .1 seconds or so set the Clicks per second to Total clicks and multiply by 10 (.1 seconds x 10 = 1 second) and display this value..But i know that this logic is flawed in some way, as is displayed by my output which only shows the total clicks value.
    I worked for a few hours trying to get this and i just can't quite wrap my head around it...Any help at all would be glorious and greatly appreciated. I hope this made it a little more clear...
  • KevinCrossKevinCross London, UKMember Posts: 1,894
    edited December 2013
    Not tried this:

    Rule: If touch is pressed
    ..Rule: If self.timerRunning = False
    ....Change Attribute: self.timerRunning = True
    ....Timer: After 1 second (run to completion)
    ......Change Attribute: self.CIS = 0
    ......Change Attribute: self.timerRunning = False
    ..Change Attribute: self.clicks = self.clicks + 1
    ..Change Attribute: self.CIS = self.CIS + 1

    I'm on my phone so the dots represent nesting
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    Unless I'm missing something, wouldn't this work (see attached demo)?

    Constrain attribute game.CPS to game.Clicks/game.Time

    I know you said you wanted various complexities such as a 2-second delay. I didn't add that but I think the basic functionality works.

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

  • CrumbyEntertainmentCrumbyEntertainment Member, PRO Posts: 32
    tatiang, thank you for the template, i actually have gotten this far but what it does is it returns the TOTAL clicks/game time. essentially that means that if i clicked 10 in the first second then none for 20 seconds the number never reaches 0, it only gets smaller.
    Kevincross, I tried what you suggested and it too did not work. I know this has to be possible, as it is not a complex task but something about the logic just hasn't clicked yet.
    Im sure we will figure it out eventually.
    Thanks for the help everyone.
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    You'll need a separate time attribute that you create with a timer that you can then reset to 0 when the player hasn't clicked in two seconds. Base your clicks per second off of this time instead of game or scene time.

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

Sign In or Register to comment.