WEEK 06
1.利用最新版processing,在執行視窗上顯現不同字體
案Enter可以換行
10.完善遊戲體驗,有多個不同單字隨機出現,並且在打完對應單字時出現下一個不同的單字
完整程式碼:
void setup()
{
size(400,600);
textSize(20);
randomQ();
}
void randomQ()
{
int i=int(random(QQ.length ));
Q=QQ[i];
x=random(300,0);
y=random(0,100);
}
String[] QQ ={"void","setup","float","string","background","fill","BlueArchive","LeagueOfLegends","StarCraft","WarCraft","Destiny"};
String Q="hello",A="";
float x=100,y=100;
void draw()
{
background(0);
fill(#FFFFFF);text(Q,x,y);
fill(#FF0000);text(A,x,y);
ellipse(200,550,20,20);
float dx=(200-x),dy=(550-y),d=sqrt(dx*dx+dy*dy)*3;
x+=dx/d;
y+=dy/d;
if(keyPressed)
{
stroke(255,0,0);
line(200,550,x,y);
}
}
void keyPressed()
{
int i=A.length();
if(key==Q.charAt(i))
{
A+=key;
if(Q.equals(A))
{
randomQ();
A="";
}
}
}
沒有留言:
張貼留言