Coches que se chocan con una bola
boolean r, l, d, u; float x = 50, y = 50; int numcoches = 30; int xbola=30; int ybola=30; Car[] cars = new Car[numcoches]; // Declaramos el arreglo de coches void setup() { size(800, 800); frameRate(80); for (int i = 0; i < numcoches; i++) { cars[i] = new Car(color(random(255), random(255), random(255)), random(10, width - 10), random(10, height - 10), random(-5, 5)); } } void draw() { background(0); ellipse(x, y, xbola, ybola); if (r) x += 1; if (l) x -= 1; if (u) y -= 1; if (d) y += 1; for (int i = 0; i < numcoches; i++) { cars[i].drive(); if(dist(x,y,cars[i].xpos,cars[i].ypos )<27){ noLoop(); } cars[i].display(); } } void keyPressed() { if (keyCode == RIGHT) r = true; if (keyCode == LEFT) l = true; if (keyCode == UP) u = true; if (keyCode == DOWN) d = true; } ...