xxxxxxxxxx
//Made for the Interactive #WCCChallenge
//Hello Raph and Chat!
//
//I'll be out on vacation for the next challenge
//Can't wait to see what you all make
//
//Check out the fork Richard Bourne made
//Turned it into a game.
β
var togs = [];
var mice = [];
let r;
function setup() {
createCanvas(innerWidth,innerHeight);
r = max(innerWidth,innerHeight)
background(255);
let w = int(width/220)
let h = int(height/120)
for(let i = -2; i<=2; i++){
for(let j = -4; j<=4; j++){
togs.push(new Toggle(width/2.0 + 110*i,height/2.0+60*j))
}
}
}
β
function draw() {
background(255)
togs.forEach(x=>x.display())
mice.forEach(x=>x.update())
mice.forEach(x=>x.display())
for(let i = mice.length-1; i>=0; i--){
if(mice[i].click){
click(mice[i].pos.x,mice[i].pos.y)
mice.splice(i,1)
}
}
}
β
function mousePressed(){
click(mouseX,mouseY)
}
function click(x,y){
for(let i = 0 ; i < togs.length; i++){
let prev = togs[i].on;
togs[i].click(x,y)
let curr = togs[i].on;
if(!prev && curr){
let a = random(TAU)
mice.push(new Cursor(r*cos(a)+innerWidth/2,r*sin(a)+innerHeight/2,togs[i].x,togs[i].y))
}
}
}
β
β