xxxxxxxxxx
function setup() {
createCanvas(490, 400);
//color starts at light purple
background(231, 165, 255);
//variables for random colors
r = random(255);
g = random(255);
b = random(255);
}
// variable for tallyMarks
let tallyMark = 0;
// creates tally marks
function mousePressed() {
tallyMark = tallyMark + 1;
// Creating variable
let marks = 0;
//creates a loop
for (let y = 50; y <= height - 50; y = y + 50) {
for (let x = 50; x <= width - 50; x = x + 10) {
//making the cros in front of the tallies when there are five on screen
if (marks < tallyMark) {
marks = marks + 1;
if (marks % 5 == 0) {
// line that crosses in front of the tallies
line(x - 50, y + 45, x, y);
}
else
{
line(x, y, x, y + 45);
}
}
}
}
}
//clears tallies. I also added a random color function for fun. I wanted the color to start at light purple
function keyPressed() {
if (keyCode === ENTER){
clear();
tallyMark = 0;
//made background color random on refresh for fun.
background(r,g,b);
r = random(255);
g = random(255);
b = random(255);
}
}