2012年11月13日 星期二

Week09,Midtern


int jx=30;//470
int jy=420;
int jz=3;//速度
PImage img;
PImage img2;
int state=1;
int jump=0;
int savetime;
int score;
int rect1, rect2, rect3, rect4, rect5, rect6, rect7, rect8, rect9, rect10, rect11 ;
int run=70;
int rectx1, rectx2, rectx3, recty1=100, recty2=0, recty3=-100;
int speed = 1;
import ddf.minim.*;
AudioPlayer player;
Minim minim;
void setup() {
  size(750, 500);
  img = loadImage("10.png");
  img2 = loadImage("20.png");
  savetime = millis();
  minim = new Minim(this); 
  //  player = minim.loadFile("dam.mp3");
  //  player.play();
  randomRect();
}
void draw() {
  background(0, 0, 0);
  fill(185, 122, 87);
  rect(10, 70, 530, 420);
  fill(128, 0, 0);
  rect(30, 70, 490, 400);
  fill(0, 255, 255);
  textSize(20);
  text("SCORE", 120, 30);
  fill(128, 255, 128);
  textSize(50);
  text("F", 420, 55);
  fill(255, 255, 0);
  textSize(55);
  text("JUMPER", 550, 45);
  textSize(20);
  text("99161030", 640, 70);
  textSize(20);
  text("99160574", 640, 90);
  textSize(30);
  text("RECORD:", 550, 200);
  fill(128, 255, 128);
  textSize(50);
  text("F", 700, 280);
  fill(0, 255, 255);
  textSize(50);
  text("PAUSE", 570, 400);
  if  (mousePressed && 570<mouseX && mouseX<720 && 360<mouseY && mouseY<400) {
    state*=-1;
  }

  if (state==1) {
    jx+=jz;
    if (jx>=470 || jx<=30) {
      jz*=-1;
    }
  }
  if (jz==3) image(img, jx, jy);
  if (jz==-3) image(img2, jx, jy);

//  if (millis()%1000<30) {  
//    rect1=int(random(1, 12));
//    rect2=int(random(1, 12));
//    rect3=int(random(1, 12));
//    rect4=int(random(1, 12));
//    rect5=int(random(1, 12));
//    rect6=int(random(1, 12));
//    rect7=int(random(1, 12));
//    rect8=int(random(1, 12));
//    rect9=int(random(1, 12));
//    rect10=int(random(1, 12));
//  }
  fill(185, 122, 87); 
 
  recty1 += 1;
  recty2 += 1;
  recty3 += 1;
//  recty4 += 1;
//  recty5 += 1;
//  recty6 += 1;
//  recty7 += 1;
//  recty3 += 1;
//  recty3 += 1;
  rect(rectx1, recty1, 100, 10);
  rect(rectx2, recty2, 100, 10);
  rect(rectx3, recty3, 100, 10);
//   if(rect1==1){  rect(30,run++, 100, 10);  } 
//   if(rect1==2){  rect(70,run++, 100, 10);  } 
//   if(rect1==3){  rect(110,run++, 100, 10);  } 
//   if(rect1==4){  rect(150,run++, 100, 10);  } 
//   if(rect1==5){  rect(190,run++, 100, 10);  } 
//   if(rect1==6){  rect(230,run++, 100, 10);  }
//   if(rect1==7){  rect(270,run++, 100, 10);  }
//   if(rect1==8){  rect(310,run++, 100, 10);  }
//   if(rect1==9){  rect(350,run++, 100, 10);  } 
//   if(rect1==10){  rect(390,run++, 100, 10);  }   
//   if(rect1==11){  rect(420,run++, 100, 10);  }
  textSize(24);
  text(+score, 120, 60);
  int passtime = millis() - savetime;
  int gametime = 20-passtime/1000;
  textSize(24);
  text("TIME: "+gametime, 590, 140);
  if ( gametime <= 0 ) {
    background(0, 0, 0);
    fill(255, 0, 0);
    textSize(40);
    text(" Time's up !! ", 260, 180);
    text(" SCORE : "+score, 240, 330);
  }
  if (jy-30<recty1 && jx>rectx1)  jy=recty1-30;
  if (jy>=420) jy=420;
  println(mouseY);
}
void randomRect() {
  rectx1 = int(random(30, 420));
  rectx2 = int(random(30, 420));
  rectx3 = int(random(30, 420));
}
void keyPressed()
{
  if (key==' ') {
    jy-=80;
    score=score+=10;
  }
}


還需要改進的部分有: (1)一開始長方體為固定人物漸漸往上跳,鏡頭也可以漸漸帶上去,接連下來有隨機的長方體 (2)每爬上一定的距離FLOOR就會慢慢增加並顯示出來 (3)會留下最高紀錄

沒有留言:

張貼留言