2013年12月23日 星期一

Week 16

期末作品
PROCESSING

PImage bg,blu,white,yellow,blu2,white2;
int N=6;
int count = 1500;
float []thingX=new float[6], thingY=new float[6],thingType = new float[6];
int grade=0;
void setup(){
  bg = loadImage("bg.jpg");
  blu = loadImage("blu.jpg");
  white = loadImage("white.jpg");
  yellow = loadImage("yellow.jpg");
  blu2 = loadImage("blu2.jpg");
  white2 = loadImage("white2.jpg");
  size(400,600);
  for(int i=0;i<N;i++){
    newThing(i);
  }
}
int countDown=10*30;
void draw(){
  image(bg,0,0, 400,600);
  image(blu,13,475,60,15);
  image(white,73,475,66,15);
  image(yellow,139,475,88,15);
  image(blu2,293,475,64,15);
  image(white2,227,475,66,15);
  if(countDown>0){
    background(255,0,255);
    countDown--;
    text("Count Down"+countDown/50,170,300);
    return;
  }
  for(int i=0;i<N;i++){
    if(thingType[i]==1)
    {
     drawblu(i);
      if (keyPressed)
      {
        if(key=='d'|| key=='D')
        if(450<thingY[i] && thingY[i]<500)
        {
          thingY[i] = 650; grade++; println(grade);
          fill(#0046FF,90);
          rect(10,475,66,-500);
        }
      }
     
    }
    else if(thingType[i]==2)
    {
      drawwhite(i);
      if (keyPressed)
      {
        if(key=='f'|| key=='F')
        if(450<thingY[i] && thingY[i]<500)
        {
        thingY[i] = 650; grade++; println(grade);
        fill(255,90);
        rect(73,475,66,-500);
        }
      }
    }
    else if(thingType[i]==3)
    {
      drawyellow(i);
      if (keyPressed)
      {
        if(key=='b'|| key=='B')
        if(450<thingY[i] && thingY[i]<500)
        {
        thingY[i] = 650; grade++; println(grade);
        fill(#FFF700,90);
        rect(139,475,66,-500);
      }
      }
    }
    else if(thingType[i]==4)
    {
      drawblu2(i);
      if (keyPressed)
      {
        if(key=='k'|| key=='K')
        if(450<thingY[i] && thingY[i]<500)
        {
        thingY[i] = 650; grade++; println(grade);
        fill(#0046FF,90);
        rect(293,475,66,-500);
      }
      }
    }
    else if(thingType[i]==5)
    {
      drawwhite2(i);
      if (keyPressed)
      {
        if(key=='j'|| key=='J')
        if (450<thingY[i] && thingY[i]<500)
        {
          thingY[i] = 650; grade++; println(grade);
          fill(255,90);
          rect(227,475,66,-500);
        }
      }
    }
    thingY[i]+=4;//掉的速度
    if(thingY[i]>600) newThing(i);
   }
  if(count>0){
    count--;
    text("Time: "+count/50,170,300);
    }
    if(count==0){
      background(#FF0015);
      text("Score: "+grade,122,300);
    }
}
void newThing(int i){
  thingY[i] = -random(200);
  thingX[i] = random(400);
  thingType[i] = int(random(5))+1;
}
void drawblu(int i){
  thingX[i]=int(random(13,13));
  image(blu,thingX[i],thingY[i],60,15);
}
void drawwhite(int i){
  thingX[i]=int(random(73,73));
  image(white,thingX[i],thingY[i],66,15);
}
void drawyellow(int i){
  thingX[i]=int(random(139,139));
  image(yellow,thingX[i],thingY[i],88,15);
}
void drawblu2(int i){
  thingX[i]=int(random(293,293));
  image(blu2,thingX[i],thingY[i],66,15);
}
void drawwhite2(int i){
  thingX[i]=int(random(227,227));
  image(white2,thingX[i],thingY[i],66,15);
}

沒有留言:

張貼留言