Created
February 3, 2021 22:52
-
-
Save zamfi/d39f549e0142ed28def910e52ca92ec6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// "number in box" - try clicking in the window | |
// this is the "data" | |
var c = 0; | |
var x = 50; | |
var y = 50; | |
function setup() { | |
createCanvas(340, 340); | |
} | |
// this is the "render" function | |
function draw() { | |
background(220); | |
noStroke(); | |
fill('red'); | |
rect(x, y, width/4, height/4); | |
fill(0); | |
textSize(32); | |
text(c, x+10, y+32); | |
} | |
// this function detects a mouse click (an event) | |
function mousePressed() { | |
x = mouseX + 0; | |
y = mouseY + 0; | |
c = c + 1; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment