#FLcreativecoding 25 Squares A
/*
* Creative Coding
* Week 2, 03 - n squares
completely rec0det by Marius Ivaskevicius
*/
class Square{
int xPos;
int yPos;
int DesX;
int DesY;
int size=50;
int h=10;
int speed=10;//record2 else10-----------------------------------------------------------------------------------
void teleport(int x,int y){
this.xPos=this.DesX=x;
this.yPos=this.DesY=y;
}
void target(int x,int y){
this.DesX=x;
this.DesY=y;
}
void update(){
this.xPos-=(this.xPos-this.DesX)/speed;
this.yPos-=(this.yPos-this.DesY)/speed;
fill(128,61,0,100); // shadow
rect(this.xPos+this.h,
this.yPos+this.h,
this.size,
this.size);
fill(255,136,4,200); // rectangle
rect(this.xPos,
this.yPos,
this.size,
this.size);
}
}
int eventCounter=0;
int eventCounterTot=100;//record5 else100 ------------------------------------------------------------------------
int eventNumber=0;
int sqrTot=100;
//int[] arr= new int[10];
//arr[1]=0;
Square[] squares;
void setup() {
size(800, 600);
rectMode(CENTER);
noStroke();
int stepX=width/11;
int stepY=height/11;
squares= new Square[100];
for(int i=0;i
squares[i].teleport(i%10*stepX+stepX,i/10*stepY+stepY);
}
//frameRate(1);//record ------------------------------------------------------------------------------------------
}
void draw() {
background(90,114,169); // clear the screen to grey
int stepX=width/11;
int stepY=height/11;
for(int i=0;i
}
if(++eventCounter>=eventCounterTot){
eventCounter=0;
for(int i=0;i
i/ 10 *stepY+stepY+int(random(-40,40)));
}
}
//saveFrame("sqrn####.jpg");//record -------------------------------------------------------------------------
} //end of draw
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home