Simple mouse clicked counter question
in
Programming Questions
•
10 months ago
I am trying to set up a code that will display the number 0 on the screen and increase the number by 1 every time the mouse is clicked.
my code so far is below , however I am not sure what i need to set this up correctly. Can anyone help? Thanks
- Counter cntr;
- int scr = 0;
- //float xpos;
- //float ypos;
- void setup() {
- size(500, 500);
- cntr= new Counter();
- }
- void draw() {
- background(255);
- cntr.display();
- if (mousePressed == true) {
- scr++;
- }
- }
- class Counter {
- Counter() {
- }
- void display() {
- text (""+scr, 250, 250);
- }
- }
1