2023年10月19日 星期四

Week06

 size(500,500);

textSize(64);

text("Hello World",100,100);


fill(255,0,0);

text("Red",100,200);

//單純印字


void setup(){
  size(500,500);
  textSize(64);
}
String line ="Input: ";
void draw(){
  text(line,100,100);//show text
}
void keyPressed(){
  line+=key;//打字
}


void keyPressed(){
  if(key>='A'&&key<='Z') line+=key;
  if(key>='a'&&key<='z') line+=key;

}



import processing.sound.*;
SoundFile Ball,John,oof;
void setup(){
  size(800,500);
  Ball = new SoundFile(this ,"Ball.mp3");
  John = new SoundFile(this ,"John.mp3");
  oof = new SoundFile(this ,"oof.mp3");
}
void draw(){
  text("press 1,2,3",100,100);
}
void keyPressed(){
  if(key=='1') Ball.play();
  if(key=='2') John.play();
  if(key=='3') oof.play();
}




import processing.sound.*;
SoundFile oof;
void setup(){
  size(800,500);
  textSize(64);
  
  oof = new SoundFile(this ,"oof.mp3");
}
String line ="";
void draw(){
  background(0);
  text("Input: "+line,50,100);
}
void keyPressed(){
  if(key>='A'&&key<='Z') {line+=key;oof.play();}
  if(key>='a'&&key<='z') {line+=key;oof.play();}
  if(key==BACKSPACE && line.length()>0 ) {
    line=line.substring(0,line.length()-1);
    oof.play();
  }
  if(key==ENTER){
    oof.play();
  }
}


void setup(){
  size(400,600);
  textSize(12);
}
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;
  }
}




沒有留言:

張貼留言