header

bewegende alien                                       terug naar de inleiding
De alien wordt groter en kleiner en beweegt zich in x en y richting
 


float x; 
float y; 
float ny; 
float nx;
float groei = 0.5; 
float snelhx = 1; 
float snelhy = 1;
 
void setup() { 
 size(960, 540); 
 x = width/2; 
 y = height/2; 
 ny = height/15; 
 nx = height/15; 
}
void draw() 

{ 
 background(#E6FBFF); 
 fill(255, 0, 0); 
 //--------------------hoofd-----------------------// 
 beginShape(); 
 { 
 vertex(x-nx/2, y); //1 
 vertex(x-nx/2, y-ny); //2 
 vertex(x-2.5*nx, y-3*ny); //3 
 vertex(x-2.5*nx, y-4*ny); //4  
 vertex(x-nx/2, y-2*ny); //5 
 vertex(x, y-2.5*ny); //6 
 vertex(x+nx/2, y-2*ny); //7 
 vertex(x+2.5*nx, y-4*ny); //8 
 vertex(x+2.5*nx, y-3*ny); //9 
 vertex(x+nx/2, y-ny); //10 
 vertex(x+nx/2, y); //11 
 endShape(CLOSE); 
 }

fill(0, 0, 255); 
 //ogen 
 ellipse(x-nx/2, y-3*ny, nx/2, ny); 
 ellipse(x+nx/2, y-3*ny, nx/2, ny); 
 //mond 
 fill(255, 255, 0); 
 rectMode(CENTER); 
 rect(x, y-5*ny/3, 1.5*nx, ny/4); 
 fill(255,0,0); 
 //schedel 
 arc(x, y-3*ny, 3*nx, 6*ny, radians(180), radians(360)); 
  
 //--------------------Lichaam---------------------------//
 
fill(200, 200, 0); 
 beginShape(); 
 {  
 vertex(x-1.5*nx, y+7*ny); //1 
 vertex(x-2.5*nx, y+2.5*ny); //2 
 vertex(x-nx, y+ny); //3 
 vertex(x-4.5*nx, y); //4 
 vertex(x+4.5*nx, y); //5 
 vertex(x+nx, y+ny); //6 
 vertex(x+2.5*nx, y+2.5*ny); //7 
 vertex(x+1.5*nx, y+7*ny); //8 
 vertex(x, y+3*ny); //9 
 endShape(CLOSE); 
 } 
 fill(255, 0, 0); 
 rectMode(CENTER); 
 rect(x, y+ny, 2*nx, ny/4);
//Hier wordt nx negatief !! 
 // nx = nx +0.5; 
 // if (nx > height/2) nx = nx *-0.5;
nx = nx + groei; 
 ny = ny + groei;
if (nx > height/10 || nx < height/30) groei = groei *-1;
x = x + snelhx; 
 y = y + snelhy;
if (x > width || x < 0) snelhx= snelhx * -1; 
 if (y > height || y < 0) snelhy= snelhy * -1; 
}