Courses‎ > ‎AP Computer Science 2‎ > ‎Konstantinovich‎ > ‎

2017-05-25

posted May 25, 2017, 7:04 AM by Samuel Konstantinovich
On your PERSONAL computers, download processing here:
www.processing.org

The labs will be updated to have Processing by early next week!

Today: 
1. Finalize partners. 
2. Discuss Final Project Ideas. Remember: You don't have to make something original! Cloning an existing idea is already a very ambitious task. (Making a good copy is hard enough) This is true for games as well as normal programs. 
3. Start making the following:

-Project Description
Include the scope of the project, the 
-In depth UML diagram. 
Feel free to prototype using pen/paper, but when you are mostly done, type up a copy for next week.


Yesterday's Demo
Main Tab:

ArrayList<Face> lof;

public void setup() {
  size(800, 600);
  lof = new ArrayList<Face>();
  lof.add( new Face(width/3*2, height/2, 100));
  lof.add( new Face(width/3, height/2, 100));
}
public void draw() {

  background(200);
  for (Face a : lof) {
    a.display();
    a.x+= random(11)-5.5;
    a.y+= random(11)-5.5;
  }
}


void mousePressed() {
  int s = lof.size();
  for ( Face next : lof.toArray(new Face[0])) {
    for (Face newFace : next.breakIntoNPieces(5)) {
      lof.add(newFace);
    }
  }
  while (s>0) {
    lof.remove(0);
    s--;
  }
}


Face Class:

class Face {
  float x, y, size;
  

  
  ArrayList<Face> breakIntoNPieces(int n){
    ArrayList<Face> result = new ArrayList<Face>();
    while(n > 0){
      result.add(new Face(x,y,size*.6));
      n--;
    }
    return result;
  }

  Face(float x, float y, float size) {
    this.x = x;
    this.y = y;
    this.size = size;
  }

  public void display() {
    stroke(0);
    fill(255);
    rect(x, y, size, size);
    fill(255,0,0);
    noStroke();
    ellipse(x+size*.01*30, y+size*.01*30, size*.01*20, size*.01*20);
    ellipse(x+size*.01*70, y+size*.01*30, size*.01*20, size*.01*20);
    rect(x+size*.01*20, y+size*.01*80, size*.01*60, size*.01*10);
  }
}




Comments