Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Structures
- {
- float r, g, b;
- Structures()
- {
- r=0;
- g=233;
- b=233;
- box = createShape();
- box.beginShape();
- //box.stroke(#FFF758);
- //box.strokeWeight(2);
- box.vertex(170, 700);
- box.vertex(378, 585);
- box.vertex(1025, 700);
- box.vertex(1025, 1050);
- box.vertex(378, 1095);
- box.vertex(170, 1020);
- //box.vertex(378, 585);
- //box.vertex(378, 1095);
- //box.quad(, , , );
- box.endShape();
- shapeMode(CENTER);
- }
- void render()
- {
- {
- float r=flyer.velocity.x;
- // r = map(r,0,width,0,255);
- float g = flyer.velocity.y;
- // g = map(g,0,height,0,255);
- float theta = atan2(g,r)+PI;
- println(theta);
- colorMode(HSB,TWO_PI,100,100);
- box.setFill(color(theta,100,80));
- shape(box, width/2, height/2, width/3, height/4);
- //setFill(random(244));
- colorMode(RGB,255,255,255,255);
- }
- }
- }
- ///////////////////////////
- class Flyer1
- {
- float x, y, vx, vy;
- PVector location;
- PVector velocity;
- PVector acceleration;
- float topspeed;
- Flyer1()
- {
- location=new PVector(random(0, width), random(0, height));
- velocity=new PVector(0, 0);
- topspeed=10;
- }
- void update()
- {
- PVector direction = new PVector((random(width/2, width)-(width/2)), (random(height/2, height)-(height/2)));
- PVector acceleration = PVector.sub(direction, location);
- acceleration.setMag(0.2);
- velocity.add(acceleration);
- velocity.limit(topspeed);
- location.add(velocity);
- }
- void display()
- {
- stroke(255);
- strokeWeight(2);
- fill(127);
- ellipse(0+location.x, 0+location.y, 48, 48);
- }
- }
- class Flyer
- {
- float x, y, vx, vy;
- PVector location;
- PVector velocity;
- PVector acceleration;
- float topspeed;
- Flyer()
- {
- location=new PVector(random(0, width), random(0, height));
- velocity=new PVector(0, 0);
- topspeed=10;
- }
- void update()
- {
- PVector direction = new PVector((random(width/2, width)-(width/2)), (random(height/2, height)-(height/2)));
- PVector acceleration = PVector.sub(direction, location);
- acceleration.setMag(0.2);
- velocity.add(acceleration);
- velocity.limit(topspeed);
- location.add(velocity);
- }
- void display()
- {
- stroke(255);
- strokeWeight(2);
- fill(127);
- ellipse(0+location.x, 0+location.y, 48, 48);
- }
- }
- ///////////////////////////////
- class Lines
- {
- float x, y, vx, vy;
- Lines()
- {
- x=0;
- y=0;
- }
- void update()
- {
- x=x+2;
- }
- void display()
- {
- pushMatrix();
- translate(x, 0);
- stroke(a, noise(x*0.01, y*0.01, 12395)*255, noise(x*0.01, y*0.01, 12395)*255);
- //stroke(255);
- strokeWeight(3);
- line(0, 0, 0, height);
- popMatrix();
- }
- }
- ///////////////////////////////
- //Globals
- Lines l;
- ArrayList<Lines> lines;
- int delay, delayCount, numLines, lineCount;
- float freq= 10;
- float a = frameCount;
- float ang=radians(40);
- Flyer flyer;
- Flyer1 flyer1;
- Structures structure;
- PShape box;
- Flyer[] flyers = new Flyer[50];
- ///////////////////////////////
- void setup()
- {
- fullScreen(P2D);
- l = new Lines();
- lines= new ArrayList<Lines>();
- delay =int(random(0, 90));//limiting variable
- delayCount=0;
- numLines=int(random(1, 20));//limiting variable
- lineCount=0;
- structure= new Structures();
- flyer=new Flyer();
- flyer1=new Flyer1();
- for(int i = 0; i < flyers.length;i++)
- {
- flyers[i] = new Flyer();
- }
- }
- void draw()
- {
- background(0);
- flyer.update();
- flyer.display();
- //flyer1.update();
- //flyer1.display();
- for(int i = 0; i < flyers.length;i++)
- {
- flyers[i].update();
- flyers[i].display();
- }
- if (delayCount<delay)
- {
- delayCount++;
- } else
- {
- if (lineCount<numLines)
- {
- lineCount++;
- lines.add(new Lines());
- } else
- {
- delayCount=0;
- lineCount=0;
- delay =int(random(0, 90));
- numLines=int(random(1, 20));
- }
- }
- //l.update();
- //l.display();
- //for (int i=0; i< 2*height; i+=1)
- //{
- // x+=sin(ang)*amp;
- // y+=cos(ang)*amp;
- // stroke(a, noise(x*0.01, y*0.01, 12395)*255, noise(x*0.01, y*0.01, 12395)*255);
- // vertex(frameCount, y);
- // if (x>=width)
- // {
- // x=0;
- // }
- //}
- if (mousePressed)
- {
- for (int i=0; i<1; i++)
- {
- lines.add(new Lines());
- }
- }
- for (int i=0; i<lines.size(); )
- {
- if (lines.get(i).x > width)
- {
- lines.remove(i);
- //println("remove");
- } else
- {
- lines.get(i).update();
- lines.get(i).display();
- i++;
- }
- }
- structure.render();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement