今日體驗hTc VIVE
今日實作 打字遊戲
step1: install SOUND & VIEDO in library
step2: 加入音樂於背景中
step3: 加上打字的遊戲
以英文字母為例
**ctrl +T可以排版
step4: 設計字母掉下射擊遊戲
void setup(){
size(600,400); //場景大小
}
int shooting=0;
float boxX=200, boxY=0; //設定浮點
int c=0;
char [] boxC = {'a','b','c','d','e','f','g','h','i','j','k','l',
'm','n','o','p','q','r','s','t','u','v','w','x','y','z'}; //設定掉下字母
void draw(){
background(255);
boxY+=2;
if(boxY>400){
c = int(random(26));
boxY=0;
}
fill(255); rect(boxX, boxY, 50,50);
fill(255,0,0); textSize(80); text(boxC[c], boxX, boxY);
if(shooting>0){
strokeWeight(40); stroke(255,0,0); line(300,400, boxX, boxY);
strokeWeight(1); shooting--;
if(shooting==0){
c = int(random(26)); boxX=random(400)+100;
boxY=0;
}
}
}
void keyPressed(){
if(key==boxC[c]){
shooting=10;
}
}
size(600,400); //場景大小
}
int shooting=0;
float boxX=200, boxY=0; //設定浮點
int c=0;
char [] boxC = {'a','b','c','d','e','f','g','h','i','j','k','l',
'm','n','o','p','q','r','s','t','u','v','w','x','y','z'}; //設定掉下字母
void draw(){
background(255);
boxY+=2;
if(boxY>400){
c = int(random(26));
boxY=0;
}
fill(255); rect(boxX, boxY, 50,50);
fill(255,0,0); textSize(80); text(boxC[c], boxX, boxY);
if(shooting>0){
strokeWeight(40); stroke(255,0,0); line(300,400, boxX, boxY);
strokeWeight(1); shooting--;
if(shooting==0){
c = int(random(26)); boxX=random(400)+100;
boxY=0;
}
}
}
void keyPressed(){
if(key==boxC[c]){
shooting=10;
}
}
沒有留言:
張貼留言