Clicks Per Second
AngryBoi
Member Posts: 586
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
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
Thanks , will try
It is just displaying "nan" Anyone else know ho to do this?
If you don't know what I mean, Cookie Clicker had one in their game. The CPS calculator at the top
Yes, did you try either of the workarounds I mentioned?
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
Typed in the first workaround wrong! Works now. Thanks.
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.
round(X) will round to the nearest whole number.
Example: round(45.224) = 45
Example: round(45.721) = 46
Timer, after 1 second change the counter attribute to 0.
@socks the number is rounding to the nearest decimal . Ex. 45.9 And I don't have a counter attribute.
Never mind about my second statement. I made another attribute that is the same as the clicks.
I'm not sure what this means, did you try my suggestion above ?
"how can I make it so after 1 second, the counter goes back to zero?"
What is this 'counter' you are referring to ?
The "per second number"
Okay guys, I don't need help with those anymore.
How could I implement the words "Clicks per Second" before the numbers?
@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
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
Ok
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?
I would
I would round the value seconds and clicks per second, but perhaps you need a exact value.
This is the same question.
Contact me for custom work - Expert GS developer with 15 years of GS experience - Skype: armelline.support
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
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
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.
Contact me for custom work - Expert GS developer with 15 years of GS experience - Skype: armelline.support
Maybe this thread will help:
http://forums.gamesalad.com/discussion/comment/530851/#Comment_530851
@armelline it didn't work, the calculator got harder to move up the more you played
Has anyone ever made a cookie clicker style game
Try something like this.
@RThurman Wow. Sincerely breathtaking. It works as if I was dwelling in heaven. Thank you to the bottom of my heart, wise man.
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.