level 5
好人都是发车重来都不犹豫
String str[] = {"acc0","acc1","damp","loc0","loc1"};
int ds = str.length ;
boolean gray[] = new boolean [ds];
boolean inline[] = new boolean [ds];
boolean inlineY[] = new boolean [ds];
float num [] = new float [ds];
float num0[] = new float [ds];
color up1[] = new color [ds];
color bot[] = new color [ds];
int bx = 100,by = 12;
int x0 = 50,y0 = 10;
int disy = 20;
String str[] = {"acc0","acc1","damp","loc0","loc1"};
int ds = str.length ;
boolean gray[] = new boolean [ds];
boolean inline[] = new boolean [ds];
boolean inlineY[] = new boolean [ds];
float num [] = new float [ds];
float num0[] = new float [ds];
color up1[] = new color [ds];
color bot[] = new color [ds];
int bx = 100,by = 12;
int x0 = 50,y0 = 10;
int disy = 20;
int protect_lock = 0;
color c1 = color(0,105,140),
c2 = color(0,54,82),
c3 = color(255),
c4 = color(132,130,131),
c5 = color(128,0,128);
color cback = c1,
cnum = c2,
cgay = c3,
cus = c4,
cs = c5;
void setup(){
smooth();
size(800,500);
for (int i = 0;i<ds;i++){
gray[i] = false ;
up1 [i] = c2;
bot [i] = c2;
num [i] = random(0,100) ;
num0[i] = num [i] ;
}
}
void draw(){
drag();
background(127);
for(int i =0 ; i < str.length ; i++){
contrler(str[i],x0,y0+i*disy,gray[i],num[i],num0[i],i,up1[i]);
}
protect_lock -=1 ;
}
void contrler( String st1, int x,int y , boolean gra , float num , float num0 ,int who , color co) {
if (gra == false){
stroke(0);
fill (cback);
rect (x,y,bx,by);
fill (co);
noStroke();
rect (x+1,y+1,num,by-1);
stroke(0);
fill (bot[who]);
rect (x+bx+10,y,by,by);
textAlign(LEFT);
fill (255);
text (st1,x-40,y+10);
text (num0,x+10,y+10);
mouse_act(x,y,who);
}else{
stroke(0);
fill (c5);
rect (x,y,100,by);
stroke(125);
fill (125);
rect (x+120,y,by,by);
textAlign(LEFT);
text ("0.000",x-40,y+10);
stroke(0);
fill (bot[who]);
rect (x+bx+10,y,by,by);
fill (255);
text (st1,x-40,y+10);
mouse_act(x,y,who);
}
}
void mouse_act(int x, int y, int who){ //cau where the mouse is
if (mouseX>=x & mouseX<=x+bx){
if (mouseY>=y & mouseY<=y+by){
up1[who] = c5;
inline[who] = true ;
inlineY[who] = true ;
}else{
up1[who] = c2;
inline[who] = false ;
inlineY[who] = false;
}
inlineY[who] = false;
}else{
up1[who] = c2;
inline[who] = false ;
}
if (mouseX>=x+bx+10 & mouseX<=x+bx+10+by){
if (mouseY>=y & mouseY<=y+by){
if( mousePressed == true){
locked(who);
protect_lock = 25 ;
}
}
}
}
void locked(int who){
if (protect_lock <=0 ){
if (bot[who] == c2){
bot[who] = c5;
gray[who] = true ;
}else{
bot[who] = c2;
gray[who] = false;
}
}
}
void drag(){
if (mousePressed == true){
for (int i = 0 ; i<ds ; i++){
if (inline[i]){
num[i] = mouseX-x0;
num0[i] = map (mouseX-x0,0,bx,0,100);
}
}
}
}
int protect_lock = 0;
color c1 = color(0,105,140),
c2 = color(0,54,82),
c3 = color(255),
c4 = color(132,130,131),
c5 = color(128,0,128);
color cback = c1,
cnum = c2,
cgay = c3,
cus = c4,
cs = c5;
void setup(){
smooth();
size(800,500);
for (int i = 0;i<ds;i++){
gray[i] = false ;
up1 [i] = c2;
bot [i] = c2;
num [i] = random(0,100) ;
num0[i] = num [i] ;
}
}
void draw(){
drag();
background(127);
for(int i =0 ; i < str.length ; i++){
contrler(str[i],x0,y0+i*disy,gray[i],num[i],num0[i],i,up1[i]);
}
protect_lock -=1 ;
}
void contrler( String st1, int x,int y , boolean gra , float num , float num0 ,int who , color co) {
if (gra == false){
stroke(0);
fill (cback);
rect (x,y,bx,by);
fill (co);
noStroke();
rect (x+1,y+1,num,by-1);
stroke(0);
fill (bot[who]);
rect (x+bx+10,y,by,by);
textAlign(LEFT);
fill (255);
text (st1,x-40,y+10);
text (num0,x+10,y+10);
mouse_act(x,y,who);
}else{
stroke(0);
fill (c5);
rect (x,y,100,by);
stroke(125);
fill (125);
rect (x+120,y,by,by);
textAlign(LEFT);
text ("0.000",x-40,y+10);
stroke(0);
fill (bot[who]);
rect (x+bx+10,y,by,by);
fill (255);
text (st1,x-40,y+10);
mouse_act(x,y,who);
}
}
void mouse_act(int x, int y, int who){ //cau where the mouse is
if (mouseX>=x & mouseX<=x+bx){
if (mouseY>=y & mouseY<=y+by){
up1[who] = c5;
inline[who] = true ;
inlineY[who] = true ;
}else{
up1[who] = c2;
inline[who] = false ;
inlineY[who] = false;
}
inlineY[who] = false;
}else{
up1[who] = c2;
inline[who] = false ;
}
if (mouseX>=x+bx+10 & mouseX<=x+bx+10+by){
if (mouseY>=y & mouseY<=y+by){
if( mousePressed == true){
locked(who);
protect_lock = 25 ;
}
}
}
}
void locked(int who){
if (protect_lock <=0 ){
if (bot[who] == c2){
bot[who] = c5;
gray[who] = true ;
}else{
bot[who] = c2;
gray[who] = false;
}
}
}
void drag(){
if (mousePressed == true){
for (int i = 0 ; i<ds ; i++){
if (inline[i]){
num[i] = mouseX-x0;
num0[i] = map (mouseX-x0,0,bx,0,100);
}
}
}
}
2016年05月06日 13点05分
