Everett - M

By Everett Pelayo
//this project still has some problems in the code int numSpots = 9; int numSpots2 = 48; // Declare and create the array Spot[] spots = new Spot[numSpots]; //float angle = 0; float distance; float sShake; float a = 0; float angle1; float [] spots2 = new float[numSpots2]; void setup() { size(600, 400); smooth(); noStroke(); for (int i = 0; i < spots.length; i++) { float x = random(0,width); float y = random(0,height); // Create each object a +=.3; spots[i] = new Spot(x, y, 50, a, spots); } for (int i = 0; i < spots2.length; i++) { float z = i * (PI/24) - PI; spots2[i]=z; } } void draw() { background(255); for (int i = 0; i < spots.length; i++) { spots[i].move(); // Move each object spots[i].display(); // Display each object } } class Spot { float x, y; // X-coordinate, y-coordinate float diameter; // Diameter of the circle float speed; // Distance moved each frame int direction = 1; // Direction of motion (1 is down, -1 is up); Spot[] other; float angle; // Constructor Spot(float xpos, float ypos, float dia, float sp, Spot[] o) { x = xpos; y = ypos; diameter = dia; speed = sp; other = o; } void move() { // angle += random(-0.1, 0.1); x = x + random(-a, a) ; // Update x-coordinate y = y + random(-a, a) ; // Update y-coordinate x = constrain(x, diameter, width-diameter); y = constrain(y, diameter, height-diameter); angle = atan2(mouseY-y, mouseX-x); } void display() { // x = x + random(-2, 2) ; // Update x-coordinate // y = y + random(-2, 2) ; // Update y-coordinate // translate(x, y); angle1 = random(-.1,.1); fill(0); ellipse(x, y, diameter, diameter); fill(255); ellipse(x-12, y, diameter/2.5, diameter/2.5); ellipse(x+12,y, diameter/2.5, diameter/2.5); fill(0); ellipse(x-12, y, 2, 2); ellipse(x+12, y, 2, 2); for (int i = 0; i < spots2.length; i++) { float ca = cos(spots2[i]); float sa = sin(spots2[i]); distance = dist(x, y, mouseX, mouseY); if (((distance < 150) && (spots2[i])-angle < PI/(distance/12)) && (spots2[i]-angle > -PI/(distance/12))){ // distance = dist(x, y, mouseX, mouseY) - 5; sShake = random(25, distance-5); } else { sShake=random(diameter/2, 40); } stroke(0); line (x + ca*25, y + sa*25, x + ca*sShake, y + sa*sShake); } } }

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*