2014年6月23日 星期一

第十六週作業 鄭羽婷

期末作品主要畫面完成

PImage[] arrow=new PImage[8];
PImage[] result=new PImage[4];
int a[]= {
  132131, 132010, 323102, 210320, 231012, 103202, 210231, 323120, 213013, 132012
};
int time, Long, num, up;
PImage endImg, bkimg, stageImg, covImgA, covImgB, start;
int MX, MY, Record=5, now, I, RI;
boolean count=true, upt=true;
PImage[] man=new PImage[5];
PImage[] manH=new PImage[2];
int siteX[]= {
  50, 320, 585, 35, 310, 580
};
int siteY[]= {
  215, 310
};
int []change=new int [6];
int []score=new int [5];

PImage BK, block;

int finalScore;

int CI;
int t=0;
int manFX[]= {
  260, 460, 660, 360, 560
};
int manFY[]= {
  290, 590
};
boolean countSore=false;

boolean stageA=true, stageB=false, stageC=false;
int countTime;

void setup() {
  size(800, 800);
  laod();
  Long=(int)random(3)+3;
  num=(int)random(9);
}
boolean but=false;
void draw() {
  if (stageA)s1();
  else if (stageB)S2();
  else if (stageC)S3();
}


void s1() {
  image(start, 0, 0);
  if (mouseX>=125&&mouseX<=355&&mouseY>=470&&mouseY<=530) {
    stageA=false;
    stageB=true;
  }
}
boolean Click=true;
void S2() {
  Back();
  if (upt) {
    time++;
    AChange();
    if (count)Direction();
    else {
      image(result[RI], 675, 550, 100, 100);
    }
    if (mousePressed == true&&Click) {
      Click=false;
      count=false;
      but=true;
      int CGP=abs((100+time*2)-690);
      if (CGP<=20)RI=0;
      else if (CGP<=30)RI=1;
      else if (CGP<=40)RI=2;
      else RI=3;
    }
  }
  else {
    if (up==100) {
      count=true;
      but=false;
      up=0;
      upt=true;
      Click=true;
      for (int i=0;i<6;i++)change[i]=0;
      Y=0;
    }
    up++;
  }
}

void S3() {
  t++;
  if (CI==5)countSore=true;
  image(BK, 0, 0);
  image(block, 300, 210);
  image(block, 500, 210);
  image(block, 700, 210);
  image(block, 400, 510);
  image(block, 610, 510);
  if (countSore) {
    for (int i=0;i<5;i++) {
      image(man[i], manFX[i], manFY[i/3]);
    }
    fill(#A50202);
    textSize(32);
    text("score: "+finalScore, 400, 100);
  }

  else {
    for (int i=0;i<5;i++) {
      if (t%10>5&&score[CI]!=0&&CI==i) {
        image(man[i], manFX[i], manFY[i/3]-50);
        if (t%10==6)finalScore+=(CI-1);
        fill(#0024FF);
        textSize(32);
        text(CI-1, manFX[i]+50, manFY[i/3]-100);
      }
      else image(man[i], manFX[i], manFY[i/3]);
    }
    if (t%10==9)score[CI]--;
    if (score[CI]==0)CI++;
  }
}

void Direction() {
  if (abs(mouseX-MX)>=10||abs(mouseY-MY)>=10) {
    if (abs(mouseX-MX)>abs(mouseY-MY)) {
      if ((mouseX-MX)>=0)Record=1;
      else Record=3;
    }
    else if ((mouseY-MY)>=0)Record=2;
    else Record=0;
  }

  if (Record==now) {
    if (I<Long)I++;
  }
  MX=mouseX;
  MY=mouseY;
}
int Long2;
void AChange() {
  if (time==300) {
    if (countTime++==5) {
      stageB=false;
      stageC=true;
    }
    Long2=Long;
    Long=(int)random(3)+3;
    num=(int)random(10);
    //println(num);
    I=0;
    time=0;
    Record=5;
    count=true;
    upt=false;
  }
  else {
    int A=a[num];
    for (int i=0;i<Long;i++) {
      if (i<I) {
        change[i]=1;
        image(arrow[A%10+4], (i+1)*100, 500, 80, 80);
        image(manH[1], siteX[i], siteY[i/3], 180, 80);
      }
      else {
        image(arrow[A%10], (i+1)*100, 500, 80, 80);
        if (i==I)now=A%10;
        image(manH[0], siteX[i], siteY[i/3], 180, 80);
      }
      A/=10;
    }
  }
}
int Y;
void Back() {
  image(stageImg, 0, 0);
  if (upt==false) {
    Y+=5;
    for (int i=0;i<=2;i++) {
      if (change[i]!=1||but==false) {
        image(man[0], siteX[i], 290-Y, 180, 180);    
        if (Y==5)score[abs(0)]++;
      }
      else {
        image(man[abs(RI-4)], siteX[i], 290-Y, 180, 180);
        if (Y==5)score[abs(RI-4)]++;
      }
    }
  }
  image(covImgA, 0, 292);
  if (upt==false) {

    for (int i=3;i<Long2;i++) {
      if (change[i]!=1||but==false) {
        image(man[0], siteX[i], 400-Y, 180, 180);
        if (Y==5)score[0]++;
      }
      else image(man[abs(RI-4)], siteX[i], 400-Y, 180, 180);
      if (Y==5)score[abs(RI-4)]++;
    }
  }

  image(covImgB, 0, 383);

  image(bkimg, 0, 500);
  noStroke();
  fill(#AA0C0C);
  rect(100, 525, 600, 20, 7);

  noStroke();
  fill(#FFE603);
  rect(700, 530, -(600-time*2), 10, 7);

  image(endImg, 650, 500, 80, 80);
}
void laod() {
  arrow[0]=loadImage("up.png");
  arrow[1]=loadImage("right.png");
  arrow[2]=loadImage("down.png");
  arrow[3]=loadImage("left.png");
  arrow[4]=loadImage("up2.png");
  arrow[5]=loadImage("right2.png");
  arrow[6]=loadImage("down2.png");
  arrow[7]=loadImage("left2.png");
  endImg=loadImage("circle.png");
  bkimg=loadImage("stage4.jpg");
  stageImg=loadImage("stage.jpg");
  covImgA=loadImage("stage2.jpg");
  covImgB=loadImage("stage3.jpg");
  result[0]=loadImage("Per.png");
  result[1]=loadImage("GO.png");
  result[2]=loadImage("Co.png");
  result[3]=loadImage("Ba.png");
  man[0]=loadImage("m0.png");
  man[1]=loadImage("m1.png");
  man[2]=loadImage("m2.png");
  man[3]=loadImage("m3.png");
  man[4]=loadImage("m4.png");
  manH[0]=loadImage("mH.png");
  manH[1]=loadImage("mH2.png");
  start=loadImage("start.jpg");
  BK=loadImage("BK.jpg");
  block=loadImage("Block.png");
}

沒有留言:

張貼留言