xxxxxxxxxx
41
var x = 0;
var y = 200;
var score = 0;
function setup() {
createCanvas(400, 400);
}
function draw() {
background(220);
textAlign(CENTER);
text("Score: "+score,200,50);
//random without arguments shows numbers between 0 and 1
ellipse(x,y,50,50);
if (random(30)<1){
x = random(100,300);
y = random(100,300);
}
//if (keyIsPressed){
//x = x + 1;
//}
}
function keyPressed(){
x= x + 1
fill(random(256),random(256),random(256));
}
function mousePressed(){
if (dist(mouseX,mouseY,x,y)<25){
score = score + 1;
}
}
function keyTyped(){
if(key === 'w'){
fill(255,0,0);
}
if (key === 'p'){
fill(0,255,0);
}
}