9 กันยายน 2558

Lab3 Martin (interaction)

int pos_x;
int pos_y;
color clr_x_sign;
color clr_positive_sign;
void setup(){
size (600,600);
background(0);
frameRate(30);
clr_x_sign = color(255);
clr_positive_sign = color(255);
}

void draw(){
draw_martin(pos_x,pos_y);
if(key=='w'||key=='W'){
pos_y-=2;
if(pos_y<=-33){ pos_y=-33; } } if(key=='s'||key=='S'){ pos_y+=2; if(pos_y>=230){
pos_y=230;
}
}
if(key=='a'||key=='A'){
pos_x-=2;
if(pos_x<=-56){ pos_x=-56; } } if(key=='d'||key=='D'){ pos_x+=2; if(pos_x>=55){
pos_x=55;
}
}
}

void draw_martin(int x , int y){
background(0);
//----- Frame -----//
noStroke();
rect(x+60,y+35,480,280,2); // Frame outside
fill(0);
rect(x+100,y+75,400,200,2);// Frame inside

//----- Positive Sign -----//
fill(clr_positive_sign);
rect(x+140,y+155,140,40,2);
rect(x+190,y+105,40,140,2);

//----- X Sign -----//
fill(clr_x_sign);
quad(x+349,y+105,x+460,y+216,x+431,y+245,x+320,y+134);
quad(x+431,y+105,x+460,y+134,x+349,y+245,x+320,y+216);

//----- Tiltle -----//
fill(255);
PFont font;
font = loadFont("Arial-Black-52.vlw");
textFont(font);
textSize(52);
text("MAR", x+65 , y+365);
text("IN", x+232 , y+365);
text("GARRI", x+313 , y+365);

//----- Positive Sign Tiltle -----//
rect(x+195,y+341,36,10);
rect(x+208,y+328,10,36);
//----- X Sign Tiltle -----//
quad(x+503,y+328,x+533,y+358,x+526,y+365,x+496,y+335);
quad(x+526,y+328,x+533,y+335,x+503,y+365,x+496,y+358);
}

void keyPressed(){
if(key=='z'||key=='Z'){
clr_x_sign = color(random(0,255),random(0,255),random(0,255));
}
if(key=='x'||key=='X'){
clr_positive_sign = color(random(0,255),random(0,255),random(0,255));
}
if(key=='r'||key=='R'){
clr_x_sign = color(255);
clr_positive_sign = color(255);
}
}




ไม่มีความคิดเห็น:

แสดงความคิดเห็น