hi,今天繼續做作業
🔸由於上週和之前找的背景、槌子跟地鼠我實在是覺得不那麼可愛於是!
我打算自己畫背景然後改造一下新找到的地鼠小圖!!
🔹這是我做出來的背景
🔸由於我想要讓地鼠從泥土裡隨機冒出來,且他被揍的時候要哭
所以我找到了泥土
🔸以下是槌子
🔸以下是槌子打下去的樣子
🔸以下是我客製化的哭臉
🔸平常他還得給我笑著是吧,這是我畫的笑臉
🔹接著是我這星期打的程式碼,不過還差了一點點。
我在揍地鼠的時候,他給我全部一起哭阿。但我只想被揍的那隻地鼠哭,這部分還在想辦法。
接著就差在他被揍的時候要計算分數的部分還沒加上去。
🔸遊戲時間我設置30秒!!
PImage img,hammericon1,hammericon2,mouse1,mouse2,mainhole;
int time,score;
int[][]gopher=//地鼠陣列
{
{0,0,0},
{0,0,0},
{0,0,0}
};
void generateGopher()
{
int now = int(random(9));//0~8
gopher[now/3][now%3]=30+int(random(60));//地鼠陣列
}
void setup()
{
size(718,664);
time = 30;//倒數秒數
score = 0;//分數
img = loadImage("background.png");//匯入圖片
hammericon1=loadImage("hammericon1.png");
hammericon2=loadImage("hammericon2.png");
mouse1 = loadImage("mouse01.png");
mouse2 = loadImage("mouse02.png");
mainhole = loadImage("mainhole.png");
generateGopher();
}
void draw()
{
background(255);//背景
image(img,360,340);
score();
time();
for(int i=0;i<3;i++)
{
for(int j=0;j<3;j++)
{
if(gopher[i][j]>0)//地鼠出現
{
image(mouse1,150+j*200,260+i*150,110,100);
gopher[i][j]--;
if(gopher[i][j]==0)generateGopher();
else if(mousePressed)//換哭哭地鼠
{
image(mouse2,150+j*200,260+i*150,110,100);
}
}
else //洞要一直存在
{
image(mainhole,150+j*200,260+i*150,110,100);
}
}
}
if(mousePressed)//槌子
{
image(hammericon2,mouseX,mouseY,-200,-200);
imageMode(CENTER);
}
else
{
image(hammericon1,mouseX,mouseY,-200,-200);
imageMode(CENTER);
}
}
void mousePressed()
{
int i=mouseY/222,j=mouseX/240;
gopher[i][j]=0;
generateGopher();
}
void score()//分數
{
fill(0);
textSize(35);
text("Score:"+score,5,80);
}
void time()//時間
{
fill(0);
textSize(35);
text("Time:"+time,530,80);
if(time>0&&frameCount%60==0)
{
text("Time:"+time,530,80);
time=time-1;
}
else if(time==0)//時間倒數完,遊戲結束
{
fill(0);
textSize(45);
text("GameOver",250,200);
noLoop();
}
}
沒有留言:
張貼留言