2021年12月27日 星期一

我愛卯咪Week14

 

互動技術概論🎮


期末遊戲Day2
這禮拜開始寫程式,在聽完老師講解連續動圖後,我們寫好連續動圖的程式
PImage img,img1,img2,img3,img4,img5,img6,img7,img8,img9,img10,img11,img12,img13,img14,img15,
img16,img17;///宣告圖片
void setup(){
  size(400,600);
  img=loadImage("egg.png");///讀入圖片
  img1=loadImage("panda1.png");
  img2=loadImage("panda2.png");
  img3=loadImage("panda3.png");
  img4=loadImage("panda4.png");
  img5=loadImage("panda5.png");
  img6=loadImage("panda6.png");
  img7=loadImage("panda7.png");
  img8=loadImage("panda8.png");
  img9=loadImage("panda9.png");
  img10=loadImage("panda10.png");
  img11=loadImage("panda11.png");
  img12=loadImage("panda12.png");
  img13=loadImage("panda13.png");
  img14=loadImage("panda14.png");
  img15=loadImage("panda15.png");
  img16=loadImage("panda16.png");
  img17=loadImage("panda17.png");
  imageMode(CENTER);///圖片置中
}
讀入好照片後就可以處理連續動圖了
PImage img,img1,img2,img3,img4,img5,img6,img7,img8,img9,img10,img11,img12,img13,img14,img15,img16,img17;
int state=0,remainT=0,count=1800,count1=3000,count2=0,count3=0,x=200, y=300,win=0;
void setup(){
  size(400,600);
  img=loadImage("egg.png");
  img1=loadImage("panda1.png");
                    .
                    .
                    .
  imageMode(CENTER);
}
void draw(){
  count--;
  count1--;
  if(count==0) {state=1;count1=-1;}
  else if(count1==0) {state=3;count=-1;}
  else if(count==900) {state=0;}
  else if(count1==1500) state=2;
  if(win==5) state=10;
  if(count2==0)background(255);
  else background(#D6D4D4);
  //image( img, 0,0);
  image( img ,x,y);
  if(state==0){//餓了
    image( img1 ,x,y);
  }
  if(state==1){//餓死了
    image( img2 ,x,y);
  }
  if(state==2){//玩
    image( img3 ,x,y);
  }
  if(state==3){//無聊死了
    image( img4 ,x,y);
  }
  if(state==4){//吃
    remainT--;
    count3++;
    if(remainT>60){
      image( img5 ,x,y);
    }
    else{
      image( img6 ,x,y);
    }   
  }
  if(state==5){//吃死了
    remainT--;
    if(remainT>60){
      image( img7 ,x,y);
    }
    else{
      image( img8 ,x,y);
    }
  }
  if(state==6){//打球
    count3++;
    remainT--;
    if(remainT>60){
      image( img9 ,x,y);
    }
    else{
      image( img10 ,x,y);
    }
  }
  if(state==7){//吃球
    remainT--;
    if(remainT>60){
      image( img11 ,x,y);
    }
    else{
      image( img12 ,x,y);
    }
  }
  if(state==8){//洗澡
    remainT--;
    if(remainT>60){
      image( img13 ,x,y);
    }
    else{
      image( img14 ,x,y);
    }
  }
  if(state==9){//喝洗澡水
    remainT--;
    if(remainT>60){
      image( img15 ,x,y);
    }
    else{
      image( img16 ,x,y);
    }
  }
  if(state==10){//贏了
    image( img17 ,x,y);
  }
}
void mousePressed(){
  if(mouseX>=90&&mouseX<=160&&mouseX>=90){
    if(mouseY>10*50-25 && mouseY<10*50+50){
      if(count3>0){
        state=5;
        remainT=180;
        count=-1;
        count1=-1;
      }
      else if(state!=4&&state!=1&&state!=3&&state!=5&&state!=7){
        state=4;
        remainT=180;
        count=1800;
        win++;
      }
      else if(state==4){
        state=5;
        remainT=180;
        count=-1;
        count1=-1;
      }
    }
  }

圖片已經可以放上去了


這禮拜進度到這,但圖片內容稍改,所以下禮拜還要改一下圖



沒有留言:

張貼留言