2016 教學軟體設計 week6
2016-10-20
l Vive 介紹、設定、體驗
l 本日實作:for loop+array, 打字遊戲
打字 英文
typing game
Sketch --> Import Library ... -->Add Library --> Sound -->Install
import
processing.sound.*;
SoundFile
soundfile;
boolean []
drawkey = new boolean[26];//java
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 setup() //執行1次
{
size(600,400);
soundfile =new
SoundFile(this,"Developers.mp3");
soundfile.play();
}
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(60);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 ( Character.toUpperCase(key) == boxC[c] ){
shooting=10;
}
println(key);
}
沒有留言:
張貼留言