2021年12月20日 星期一

(☞゚ヮ゚)☞ Week13

 

✨Week13✨

flappy bird使用圖片












今日進度

碰撞偵測 失敗畫面

讓主角不會跑出畫面

PImage img,img1,img2;
float [] hole;
int N=25;
float x=100,y=100,bgx=-300,vy=2;
int time;
int a=0;
void setup()
{
  size(700,500);
  
  img =loadImage("22.png");//BG
  img1=loadImage("33.png");//sheep
  img2=loadImage("88.jpg");//WinBG

  hole=new float[N];
  for(int i=0;i<N;i++)
  {
    hole[i]=random(100,300);
  }
}

void draw()
{  
  image(img,-50,-200,width/0.7,height/0.7);
  bgx++;
  
  strokeWeight(0.6);
  fill(#BC885D);
  for(int i=0;i<N;i++)
  {
    rect(i*180-bgx+300,          0,50,hole[i]);
    rect(i*180-bgx+300,hole[i]+150,50,   1000);
  }
  
  textSize(50);
  fill(255);
  text("MouseClick!!",220,70);
  time=60-(frameCount/60);
  text("Time:"+time, 265,460);
  
  image(img1.get(5, 256*a, 256,250), x,y,width/6.5,height/4.5);
  if(frameCount%30==0) a = (a+1)%2;
  if(y<=-25)y=-25;
  if(y>=410)y=410;
  
  if(time<0)
  {
    image(img2,0,0,width,height);
    textSize(50);
    text("You're the best Clicker!!",75,280);
    image(img1.get(5, 256*a, 256,250), x,y,width/6.5,height/4.5);
    if(frameCount%60==0) a = (a+1)%2;
    if(y<=-25)y=-25;//讓主角不會掉出畫面
    if(y>=410)y=410;
  }
  
  y=y+vy;
  if (mousePressed)vy=-2;
  else vy=2;
}

跑出畫面GameOver

PImage img,img1,img2,img3;
float [] hole;
int N=25;
float x=100,y=100,bgx=-300,vy=2;
int time;
int a=0;
boolean alive=true;
void setup()
{
  size(700,500);
  
  img =loadImage("22.png");//BG
  img1=loadImage("33.png");//sheep
  img2=loadImage("88.jpg");//WinBG
  img3=loadImage("66.jpg");//LoseBG

  hole=new float[N];
  for(int i=0;i<N;i++)
  {
    hole[i]=random(100,300);
  }
}

void draw()
{  
  image(img,-50,-200,width/0.7,height/0.7);
  bgx++;
  
  strokeWeight(0.6);
  fill(#BC885D);
  for(int i=0;i<N;i++)
  {
    rect(i*180-bgx+300,          0,50,hole[i]);
    rect(i*180-bgx+300,hole[i]+150,50,   1000);
  }
  
  textSize(50);
  fill(255);
  text("MouseClick!!",220,70);
  time=10-(frameCount/60);
  text("Time:"+time, 265,460);
  
  image(img1.get(5, 256*a, 256,250), x,y,width/6.5,height/4.5);
  if(frameCount%30==0) a = (a+1)%2;
  
  if(y<=-45 || y>=430)alive=false;//如過太高或太低死亡
  if(alive==false)//死亡就換畫面
  {
    image(img3,0,0,width,height);
    textSize(80);
    fill(#AF1010);
    text("You're DEAD!!!!",62,260);
    
  }
  
  if(time<0)
  {
    image(img2,0,0,width,height);
    textSize(50);
    text("You're the best Clicker!!",65,270);
    image(img1.get(5, 256*a, 256,250), x,y,width/6.5,height/4.5);
    if(frameCount%60==0) a = (a+1)%2;
    if(y<=-25)y=-25;
    if(y>=410)y=410;
  }
  
  y=y+vy;
  if (mousePressed)vy=-2;
  else vy=2;
}

給主角一點裝飾


PImage img,img1,img2,img3,img4,img5;
float [] hole;
int N=25;
float x=100,y=100,bgx=-300,vy=2;
int time;
int a=0;
boolean alive=true;
void setup()
{
  size(700,500);
  
  img =loadImage("22.png");//BG
  img1=loadImage("33.png");//sheep
  img2=loadImage("88.jpg");//WinBG
  img3=loadImage("66.jpg");//LoseBG
  img4=loadImage("11.png");
  img5=loadImage("44.png");

  hole=new float[N];
  for(int i=0;i<N;i++)
  {
    hole[i]=random(100,300);
  }
}

void draw()
{  
  image(img,-50,-200,width/0.7,height/0.7);
  bgx++;
  
  strokeWeight(0.6);
  fill(#BC885D);
  for(int i=0;i<N;i++)
  {
    rect(i*180-bgx+300,          0,50,hole[i]);
    rect(i*180-bgx+300,hole[i]+150,50,   1000);
  }
  
  textSize(50);
  fill(255);
  text("MouseClick!!",220,70);
  time=0-(frameCount/60);
  text("Time:"+time, 265,460);
  
  image(img1.get(5, 256*a, 256,250), x,y,width/6.5,height/4.5);
  if(frameCount%30==0) a = (a+1)%2;
  
  if(y<=-45 || y>=430)alive=false;
  if(alive==false)
  {
    image(img3,0,0,width,height);
    textSize(80);
    fill(#AF1010);
    text("You're DEAD!!!!",62,260);    
  }
  
  if(time<0)
  {
    image(img2,0,0,width,height);
    textSize(50);
    text("You're the best Clicker!!",65,270);
    image(img5,x-40,y+24,width/7,height/7);
    image(img1.get(5, 256*a, 256,250), x,y,width/6.5,height/4.5);
    image(img4,x+33,y+20,width/10,height/8.5);
    if(frameCount%60==0) a = (a+1)%2;
    if(y<=-25)y=-25;
    if(y>=410)y=410;
  }
  
  y=y+vy;
  if (mousePressed)vy=-2;
  else vy=2;
}

碰撞偵測

PImage img,img1,img2,img3,img4,img5;
float [] hole;
int N=25;
float x=100,y=100,bgx=-300,vy=2;
int time;
int a=0;
boolean alive=true;
void setup()
{
  size(700,500);
  
  img =loadImage("22.png");//BG
  img1=loadImage("33.png");//sheep
  img2=loadImage("88.jpg");//WinBG
  img3=loadImage("66.jpg");//LoseBG
  img4=loadImage("11.png");
  img5=loadImage("44.png");

  hole=new float[N];
  for(int i=0;i<N;i++)
  {
    hole[i]=random(100,300);
  }
}

void draw()
{  
  image(img,-50,-200,width/0.7,height/0.7);
  bgx++;
  
  //rect(x+10,y+10,50,50);
  
  strokeWeight(0.6);
  fill(#BC885D);
  for(int i=0;i<N;i++)
  {
    rect(i*180-bgx+300,          0,50,hole[i]);
    rect(i*180-bgx+300,hole[i]+150,50,   1000);
    if(x>=i*180-bgx+225 && x<=i*180-bgx+315 && y<=hole[i]-25 )alive=false;//上方碰撞偵測 x>柱子寬度 y>柱子高度
    if(x>=i*180-bgx+225 && x<=i*180-bgx+315 && y>=hole[i]+60 )alive=false;//下方碰撞偵測
  }
  textSize(50);
  fill(255);
  text("MouseClick!!",220,70);
  time=60-(frameCount/60);
  text("Time:"+time, 265,460);
  
  image(img1.get(5, 256*a, 256,250), x,y,width/6.5,height/4.5);
  if(frameCount%30==0) a = (a+1)%2;
  
  if(y<=-45 || y>=430)alive=false;
  if(alive==false)//失敗畫面
  {
    image(img3,0,0,width,height);
    textSize(80);
    fill(#AF1010);
    text("You're DEAD!!!!",62,260);    
  }
  
  if(time<0)
  {
    image(img2,0,0,width,height);
    textSize(50);
    fill(#F0F2F7);
    text("You're the best Clicker!!",65,270);
    image(img5,x-40,y+24,width/7,height/7);
    image(img1.get(5, 256*a, 256,250), x,y,width/6.5,height/4.5);
    image(img4,x+33,y+20,width/10,height/8.5);
    if(frameCount%60==0) a = (a+1)%2;
    if(y<=-25)y=-25;
    if(y>=410)y=410;
  }
  
  y=y+vy;
  if (mousePressed)vy=-2;
  else vy=2;
}



沒有留言:

張貼留言