add clicks-per-second counter
This commit is contained in:
parent
f16927e356
commit
0c50c59d75
15
clicket.rkt
15
clicket.rkt
|
@ -19,6 +19,12 @@
|
||||||
[parent left-side]
|
[parent left-side]
|
||||||
[label (click-str)]
|
[label (click-str)]
|
||||||
[auto-resize #t]))
|
[auto-resize #t]))
|
||||||
|
(define cps 0)
|
||||||
|
(define (cps-str) (~a "Auto-clicks per second: " cps))
|
||||||
|
(define cps-msg (new message%
|
||||||
|
[parent left-side]
|
||||||
|
[label (cps-str)]
|
||||||
|
[auto-resize #t]))
|
||||||
|
|
||||||
; helper procedure
|
; helper procedure
|
||||||
(define-syntax-rule (new-inc-button container name counter)
|
(define-syntax-rule (new-inc-button container name counter)
|
||||||
|
@ -57,10 +63,13 @@
|
||||||
(define timer (new timer% [interval 100]
|
(define timer (new timer% [interval 100]
|
||||||
[notify-callback
|
[notify-callback
|
||||||
(λ ()
|
(λ ()
|
||||||
(when (= 0 (modulo timer-ctr 10))
|
(set! cps 0)
|
||||||
(for ([cl all-clickers])
|
(for ([cl all-clickers])
|
||||||
(set! clicks (+ clicks (* (clicker-multiplier cl) (clicker-count cl))))))
|
(when (= 0 (modulo timer-ctr 10))
|
||||||
|
(set! clicks (+ clicks (* (clicker-multiplier cl) (clicker-count cl)))))
|
||||||
|
(set! cps (+ cps (* (clicker-multiplier cl) (clicker-count cl)))))
|
||||||
(send click-msg set-label (click-str))
|
(send click-msg set-label (click-str))
|
||||||
|
(send cps-msg set-label (cps-str))
|
||||||
(set! timer-ctr (add1 timer-ctr)))]))
|
(set! timer-ctr (add1 timer-ctr)))]))
|
||||||
|
|
||||||
; show frame
|
; show frame
|
||||||
|
|
Loading…
Reference in a new issue