Clicks Per Second

Hello there, I am currently making a Cookie Clicker style game. How could I make it so there is a clicks per second calculator? So far, all I have is every time I click it is plus one.

Comments

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    edited June 2015

    Change attribute game.startTime (real) to game.Time

    When Mouse Button is Down
         Change attribute game.clicks to game.clicks+1

    Display Text
         game.clicks/(game.Time-game.startTime)

    You may want to use the roundTo() function inside the Display Text expression. For example, roundTo(game.clicks/(game.Time-game.startTime),1).

    Edit: when I tested this, it displayed nan (not a number) because it's dividing game.clicks by zero. I thought that would resolve when game.Time was greater than game.startTime but for some reason it doesn't. Possible workarounds are:

    roundTo( game.clicks /( game.Time - game.startTime +.001),1)

    or

    Timer After 0.1 seconds
         Display Text
              game.clicks/(game.Time-game.startTime)

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

  • AngryBoiAngryBoi Member Posts: 586

    Thanks , will try

  • AngryBoiAngryBoi Member Posts: 586

    It is just displaying "nan" Anyone else know ho to do this?

  • AngryBoiAngryBoi Member Posts: 586

    If you don't know what I mean, Cookie Clicker had one in their game. The CPS calculator at the top

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    @BetweenTheWalls said:
    It is just displaying "nan" Anyone else know ho to do this?

    Yes, did you try either of the workarounds I mentioned?

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

  • AngryBoiAngryBoi Member Posts: 586

    Typed in the first workaround wrong! Works now. Thanks.

  • AngryBoiAngryBoi Member Posts: 586

    2 more quick questions. How can I make it round to the nearest whole number, and how can I make it so after 1 second, the counter goes back to zero? I can't figure them out.

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

    @BetweenTheWalls said:
    How can I make it round to the nearest whole number . . .

    round(X) will round to the nearest whole number.

    Example: round(45.224) = 45
    Example: round(45.721) = 46

    @BetweenTheWalls said:
    and how can I make it so after 1 second, the counter goes back to zero?

    Timer, after 1 second change the counter attribute to 0.

  • AngryBoiAngryBoi Member Posts: 586

    @socks the number is rounding to the nearest decimal . Ex. 45.9 And I don't have a counter attribute.

  • AngryBoiAngryBoi Member Posts: 586

    Never mind about my second statement. I made another attribute that is the same as the clicks.

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

    @BetweenTheWalls said:
    socks the number is rounding to the nearest decimal . Ex. 45.9

    I'm not sure what this means, did you try my suggestion above ?

    @BetweenTheWalls said:
    And I don't have a counter attribute.

    "how can I make it so after 1 second, the counter goes back to zero?"

    What is this 'counter' you are referring to ?

  • AngryBoiAngryBoi Member Posts: 586

    The "per second number"

  • AngryBoiAngryBoi Member Posts: 586

    Okay guys, I don't need help with those anymore.

  • AngryBoiAngryBoi Member Posts: 586

    How could I implement the words "Clicks per Second" before the numbers?

  • AngryBoiAngryBoi Member Posts: 586

    @Tatiang After playing around with the clicks per second, I noticed after using it in-app for a while, the slower and slower it takes to go up from zero

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    The math formula is essentially total clicks divided by total elapsed time so as more time goes by it gets harder to increase the value of the formula.

    To concatenate or join text to an attribute or expression, use two periods: "Clicks per second: "..game.clicks/(game.Time-game.startTime). Note that to add spaces to an expression you'll have to hold down the option key when pressing the space key.

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

  • AngryBoiAngryBoi Member Posts: 586

    Ok

  • AngryBoiAngryBoi Member Posts: 586

    I guess I wasn't asking for the righ thing in my other discussion, but how would I make a clicks per second calculator like in Cookie Clicker?

  • ThoPelThoPel GermanyMember, PRO Posts: 184
    edited June 2015

    I would

    • save the timestamp for the first click
    • count all clicks
    • seconds = game.time - timestamp
    • clicks per second = count(touch) / seconds

    I would round the value seconds and clicks per second, but perhaps you need a exact value.

  • ArmellineArmelline Member, PRO Posts: 5,369

    This is the same question.

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    edited June 2015

    I've merged these threads. Please don't start a new thread for the same issue.

    Instead, provide more details about what you're trying to do. You asked for a "clicks per second calculator" and I provided a demo. Then you asked again for a "clicks per second calculator." You need to explain what you mean since the demo I provided isn't doing what you need. How do you want the clicks per second to be calculated? As an example, my demo (the same method as @ThoPel suggested) takes into account total clicks over the total duration. Maybe you want each second to have a separate calculation that gets reset on a timer? In that way, if you clicked 10 times the first second, it would show "Clicks per second: 10" but if you clicked 3 times the second second, it would show "Clicks per second: 3". Or is there some other way you want it to function?

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

  • AlchimiaStudiosAlchimiaStudios Member Posts: 1,069
    edited June 2015

    Are you looking for a specific way to calculate/display it other then whats been laid out? Like highest clicks per second achieved vs actively updating clicks per second?

    Follow us: Twitter - Website

  • AngryBoiAngryBoi Member Posts: 586

    Just look in the game Cookie Clicker. I don't want the calculator to get harder to raise as you play. I just want a calculator of how many clicks/points a second you are getting

  • ArmellineArmelline Member, PRO Posts: 5,369

    @BetweenTheWalls said:
    Just look in the game Cookie Clicker. I don't want the calculator to get harder to raise as you play. I just want a calculator of how many clicks/points a second you are getting

    The very first reply to your original thread, from @tatiang, tells you just how to do that.

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

    @armelline it didn't work, the calculator got harder to move up the more you played

  • AngryBoiAngryBoi Member Posts: 586

    Has anyone ever made a cookie clicker style game

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

    Try something like this.

  • AngryBoiAngryBoi Member Posts: 586

    @RThurman Wow. Sincerely breathtaking. It works as if I was dwelling in heaven. Thank you to the bottom of my heart, wise man.

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

    Now there's a happy GameSalad customer! :)

    This isn't really a clicks-per-second calculation. Clicks-per-second would imply rate -- which is what @tatiang was giving you.

    Instead, this counts the number of clicks which occurred in the previous second. And it keeps restarting the count during every second.

    One way to get clicks-per-second would be to add all the separate counts together and then divide by the number of elapsed seconds.

Sign In or Register to comment.