Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Week 23 Exercise #51

Open
chasestarr opened this issue Apr 20, 2016 · 7 comments
Open

Week 23 Exercise #51

chasestarr opened this issue Apr 20, 2016 · 7 comments
Labels

Comments

@chasestarr
Copy link
Member

screenshot 2016-04-20 10 55 06

@chasestarr
Copy link
Member Author

screenshot 2016-04-20 11 30 19

@chasestarr
Copy link
Member Author

screenshot 2016-04-20 11 32 22

@Jeswing
Copy link

Jeswing commented Apr 20, 2016

Tab 1

ParticleSystem ps= new ParticleSystem(width/2,height/2);
PVector gravityN = new PVector(0, -.1); 
void setup(){
  size(400,400);
}

void draw(){
  background(255);
  ps.addParticle();
  ps.run();
    }

void mouseClicked(){
}

Tab 2

class Particle{
PVector velocity;
PVector location;
PVector acceleration;
int lifespan;

Particle(float locX, float locY){
  location= new PVector(mouseX,mouseY);
  acceleration= new PVector();
  velocity= new PVector();
  lifespan= 255;
}
void update(){
  velocity.add(acceleration);
  location.add(velocity);
  acceleration.mult(0);
  lifespan -= 2;
}
void display(){
  stroke(0, lifespan);
  fill(175, lifespan);
  ellipse(location.x,location.y,15,15);
}
void applyForce(PVector f){
  acceleration.add(f);
}
void run(){
  update();
  display();
}

boolean isDead(){
  if(lifespan < 0){
    return true;
  }else{
    return false;
  }
}

}

Tab 3

class ParticleSystem{
ArrayList<Particle> plist;
PVector center;

ParticleSystem(float locX, float locY){
  plist= new ArrayList<Particle>();
  center = new PVector(locX, locY);
}

void addParticle(){
  plist.add(new Particle(center.x,center.y));
}

void run(){
   for (int i= 0; i < plist.size(); i++){
    Particle p= plist.get(i);
    p.run();
    p.applyForce(gravityN);
    if (p.isDead()) {
      println("Rest in Pieces");
      plist.remove(i);
}
   }
}
}

@chasestarr chasestarr mentioned this issue Apr 20, 2016
@The-Space-Core
Copy link

ParticleSystem ps = new ParticleSystem(200,200);
PVector gravityN = new PVector(0, -0.01);

void setup(){
size(400,400);
}

void draw(){
background(255);
ps.addParticle();
ps.run();
}

void mouseClicked(){
}

@The-Space-Core
Copy link

class Particle{
PVector velocity;
PVector acceleration;
PVector location;
int lifespan;

Particle(float locX, float locY){
location = new PVector(locX,locY);
acceleration = new PVector();
velocity = new PVector();
lifespan = 255;
}

void update(){
velocity.add(acceleration);
location.add(velocity);
acceleration.mult(0);
lifespan -= 2;
velocity.limit(0.1);
}
void display(){
stroke(0,1,lifespan);
fill(175,lifespan);
ellipse(location.x,location.y,8,8);
}
void run(){
update();
display();
}

void applyForce(PVector force){
acceleration.add(force);
}
boolean isDead(){
if(lifespan<0){
return true;
}else{
return false;
}

}
}

@The-Space-Core
Copy link

class ParticleSystem{
ArrayList plist;
PVector center;

ParticleSystem(float locX, float locY){
plist = new ArrayList();
center = new PVector(locX,locY);
}

void addParticle(){
plist.add(new Particle(mouseX,mouseY));
}

void run(){
for(int i = 0; i < plist.size(); i++){
Particle p = plist.get(i);
p.run();
p.applyForce(gravityN);
if (p.isDead()){
println("rent in panama");
plist.remove(i);
}
}
}
}

@Brandonsugar
Copy link

Tab 1;

ParticleSystem ps = new ParticleSystem(500,500);
PVector spon = new PVector(random(-0.1,-0.1),random(-0.1,0.1));

void setup(){
  size(1000,1000);
}

void draw(){
  background(0);
  ps.run();
  ps.addParticle();
  ps.center = new PVector(mouseX,mouseY);
}

void mouseClicked(){

}

Tab 2;

class Particle{
  PVector location;
  PVector acceleration;
  PVector velocity;
  int lifeSpan;
  //boolean isDead(){
  //  if(lifeSpan(0)){
  //    return true;
  //  } else {
  //    return false;
  //  }
  //}

  Particle(float xLoc,float yLoc){
    location = new PVector(xLoc,yLoc);
    velocity = new PVector();
    acceleration = new PVector();
    acceleration.mult(0);
    lifeSpan = 255;
  }
  void display(){
    stroke(0,lifeSpan);
    fill(255,lifeSpan);
    ellipse(location.x,location.y,20,20);
  }
  void update(){
    velocity.add(acceleration);
    location.add(velocity);
    lifeSpan -= 1;
  }
  void run(){
    update();
    display();
    borders();
  }
  void applyForce(PVector f){
    acceleration.add(f);
  }
  void borders(){
    if(location.x > width){
      velocity.x *= -0.98;
    } else if(location.x < 0){
      velocity.x *= -0.98;
    } 
    if(location.y > height){
      velocity.y *= -0.98;
    } else if(location.y < 0){
      velocity.y *= -0.98;
    }
  }
  Boolean isDead(){
    if(lifeSpan<0){
      return true;
    } else { 
      return false;
    }
}
}

Tab 3;

class ParticleSystem{
  ArrayList<Particle> PList;
  PVector center;

  ParticleSystem(float xLoc, float yLoc){
    PList = new ArrayList<Particle>();
    center = new PVector(xLoc,yLoc);
  }

  void addParticle(){
    PList.add(new Particle(center.x, center.y));
  }

  void run(){
    for(int index = 0; index < PList.size(); index++){
      Particle p = PList.get(index);
      p.run();
      p.applyForce(spon);
      if(p.isDead()){
       PList.remove(index);
      }
    }
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants