beweging1

 

 

 

 

 

 

 

 

beweging2

 

 

 

 

 

 

 

beweging3

man en vrouw methodes en twee bewegingsmethodes in de class Mens.                      terug naar de inleiding
 
De schets met 9 mensen
 
 
 

Mens m1; Mens m2; Mens m3;   
Mens m4; Mens m5; Mens m6;   
Mens m7; Mens m8; Mens m9; 
  
void setup() {   
 size(960,540);   
 //Bovenster rij  
 m1 = new Mens(width/4*1, height/4*1, height/15);  
 m2 = new Mens(width/4*2, height/4*1, height/20);  
 m3 = new Mens(width/4*3, height/4*1, height/25);  
 //Middelste rij  
 m4 = new Mens(width/4*1, height/4*2, height/25);  
 m5 = new Mens(width/4*2, height/4*2, height/20);  
 m6 = new Mens(width/4*3, height/4*2, height/15);  
 //Onderste rij  
 m7 = new Mens(width/4*1, height/4*3, height/20);  
 m8 = new Mens(width/4*2, height/4*3, height/20);  
 m9 = new Mens(width/4*3, height/4*3, height/20);  
}  
void draw() {   
 background(#E6FBFF);  
 m1.vrouw(); m2.vrouw(); m3.vrouw();   
 m1.heen(); m2.heen(); m3.heen();  
 m4.man(); m5.man(); m6.man();  
 m4.terug(); m5.terug(); m6.terug();  
 m7.vrouw(); m8.vrouw(); m9.vrouw();  
 m7.heen(); m8.heen(); m9.heen();  
}
 

De class ¨Mens¨

 

class Mens {  
 
  float x;  
  float y;  
  float n;   
 
  float henw = 1;  
 
  Mens(float x_, float y_, float n_) {  
    x = x_;  
    y = y_;  
    n = n_; 
  }  
 
  void man() {  
    //lichaam  
    fill(255, 0, 0);  
    rectMode(CENTER);  
    rect(x, y, n, n*2);  
    //hoofd  
    ellipse(x, y-1.5*n, n, n);  
    //arm li  
    rectMode(CORNER);  
    rect(x-n, y-n, n/2, n*1.5);  
    //arm re  
    rect(x+n/2, y-n, n/2, n*1.5);  
    //li been  
    rect(x-n/2, y+n, n/3, 1.5*n);    
    //Re been  
    rect(x+n/6, y+n, n/3, 1.5*n); 
  }     
  void vrouw() {  
    //lichaam  
    fill(255, 255, 0);  
    rectMode(CENTER);  
    rect(x, y-n/4, n, n*1.5);  
    //hoofd  
    ellipse(x, y-1.5*n, n, n);  
    //arm li  
    rectMode(CORNER);  
    rect(x-n, y-n, n/2, n*1.5);  
    //arm re  
    rect(x+n/2, y-n, n/2, n*1.5);  
    //jurk  
    quad(x-n, y+n*1.5, x-n/2, y+n/2, x+n/2, y+n/2, x+n, y+n*1.5);  
    //li been  
    rect(x-n/6*3, y+n*1.5, n/3, n);    
    //Re been  
    rect(x+n/6, y+n*1.5, n/3, n); 
  }  
 
  void heen() {   
    x++;   
    if (x > width) {   
      x = 0; 
    } 
  }  
 
  void terug() {   
    x--;   
    if (x < 0) {   
      x = width; 
    } 
  } 
}