arduino

arduino

Minettyx

int trashx = 20;

int spostamento = 10;

int v = 3;

int my = 1;

int mx = 35;


void setup() {

 size(400,600);

 mx = int(random(35,width - 35));

}


void draw() {

 background(0);

 my = my + v;

 if (my > height) {

  my = 1;

  mx = int(random(35,width - 35));

 }

 ellipse(mx, my, 30, 30);

 rect(trashx, height-50, 30, 30);

 stroke(255);

 //line(trashx, 0, trashx, height);

 //line(trashx+30, 0, trashx+30, height);

 //line(0,height-50,width,height-50);

 //line(0,height-20,width,height-20);

  

 //line(mx-15, 0, mx-15, height);

 //line(mx+15, 0, mx+15, height);

 //line(0,my+15,width,my+15);

 //line(0,my-15,width,my-15);

  

 if (((trashx >= mx-15 && trashx <= mx+15) || (trashx+30 >= mx-15 && trashx+30 <= mx+15)) && (my > height-50)) {

  background(255);

 }

}


void keyPressed() {

 if (keyCode == RIGHT && trashx < width - 50) {

  trashx = trashx + spostamento;

 }

 if (keyCode == LEFT && trashx > 20) {

  trashx = trashx - spostamento;

 }

}

Report Page