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(800,400);
textSize(64);
}

String line = "Input: ";
void draw(){
  text(line ,50,100);
}
void keyPressed(){
if(key>='A' && key<='Z')line += key;
if(key>='a' && key<='z')line += key;
}




void setup(){
size(800,400);
textSize(64);
}

String line = "";
void draw(){
  background(0);
  text("Input: "+line,50,100);
}
void keyPressed(){
if(key>='A' && key<='Z')line += key;
if(key>='a' && key<='z')line += key;
if(key==BACKSPACE && line.length()>0){
  line = line.substring(0,line.length()-1);
  }
}



import processing.sound.*;
//http://processing.org/reference/libraries/sound/index.html
void setup() {
  size(300, 300);
  file = new SoundFile(this, "a.mp3");
  file.play();
  
}
void draw(){
  
}


import processing.sound.*;
SoundFile dadada, good, over;
void setup() {
  size(300, 300);
  dadada = new SoundFile(this, "dadada.mp3");
  good = new SoundFile(this, "good.mp3");
  over = new SoundFile(this, "over.mp3");
}
void draw(){
  text("press 1,2,3",100,100);
}
void keyPressed(){
  if(key=='1') dadada.play();
  if(key=='2') good.play();
  if(key=='3') over.play();
}




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


沒有留言:

張貼留言