✨Week12✨
今日進度
標語 倒數計時 人物圖片 柱子距離調整
標語設置
💻程式碼
PImage img;
float [] hole;
int N=20;//設定20個障礙物
float x=100,y=200,bgx=-200,vy=2;
void setup()
{
size(700,500);
img=loadImage("22.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++;
fill(#AA7B54);
for(int i=0;i<N;i++)
{
rect(i*170-bgx+300, 0,50,hole[i]);
rect(i*170-bgx+300,hole[i]+150,50, 1000);//柱子開始的位置,洞出現的位置,柱子的寬度,柱子的長度
}
textSize(80);
fill(255);
text("MouseClick!!",120,100);//提示文字
ellipse(x,y,50,50);
y=y+vy;
if (mousePressed)vy=-2;//按住滑鼠球往上
else vy=2;
}
倒數計時一分鐘
💻程式碼
PImage img,img1,img2;
float [] hole;
int N=25;
float x=100,y=200,bgx=-200,vy=2;
int time;
void setup()
{
size(700,500);
img =loadImage("22.png");
img1=loadImage("44.png");
img2=loadImage("55.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*170-bgx+300, 0,50,hole[i]);
rect(i*170-bgx+300,hole[i]+150,50, 1000);
}
textSize(50);
fill(255);
text("MouseClick!!",220,70);
time=60-(frameCount/60);//倒數一分鐘
text("Time:"+time, 270,460);//紀錄時間
image(img1,x,y,width/7,height/5);
image(img2,x,y,width/7,height/5);
y=y+vy;
if (mousePressed)vy=-2;
else vy=2;
}
讓小羊會動
PImage img,img1;
float [] hole;
int N=25;
float x=100,y=200,bgx=-200,vy=2;
int time;
int a=0;
void setup()
{
size(700,500);
img =loadImage("22.png");
img1=loadImage("33.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*170-bgx+300, 0,50,hole[i]);
rect(i*170-bgx+300,hole[i]+150,50, 1000);
}
textSize(50);
fill(255);
text("MouseClick!!",220,70);
time=60-(frameCount/60);//倒數一分鐘
text("Time:"+time, 270,460);//紀錄時間
image(img1.get(5, 256*a, 256,250), x,y,width/6.5,height/4.5);//切割成兩張圖片
if(frameCount%20==0) a = (a+1)%2;//到時間就換動作
y=y+vy;
if (mousePressed)vy=-2;
else vy=2;
}
勝利標語
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");
img1=loadImage("33.png");
img2=loadImage("88.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%10==0) a = (a+1)%2;
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%10==0) a = (a+1)%2;
}
y=y+vy;
if (mousePressed)vy=-2;
else vy=2;
}
選定背景音樂
https://youtu.be/sdSwuDDMEzY
沒有留言:
張貼留言