2024年11月4日 星期一

week09

 size(500,500);

background(0);

textSize(50);

text("Hello",50,50);


PFont font=createFont("標楷體",50);

textFont (font);

text("中文看到了",50,150);


PFont font2=createFont("elffont-rock.otf",50);

textFont(font2);

text("ㄇㄉㄈㄎ",50,250);

size(500,500);
background(0);
textSize(50);
text("Hello",50,50);

PFont font=createFont("標楷體",50);
textFont (font);
text("中文看到了",50,150);

PFont font2=createFont("elffont-rock.otf",50);
textFont(font2);
text("ㄇㄉㄈㄎ",50,250);



PFont font0,font,font2; void setup(){ size(500,500); font0=createFont("Arial",50); font=createFont("標楷體",50); font2=createFont("elffont-rock.otf",50); } void draw(){ background(0); textSize(50); textFont(font0); text("Hello",50,50); textFont(font); text("中文看到了",50,150); textFont(font2); text("ㄇㄉㄈㄎ",50,250); }
PFont font0,font,font2;
void setup(){
  size(500,500);
  font0=createFont("Arial",50);
  font=createFont("標楷體",50);
  font2=createFont("elffont-rock.otf",50);
}
void draw(){
  background(0);
  textSize(50);
  textFont(font0);
  text("Hello",50,50);
  
  textFont(font);
  text("中文看到了",50,150);
  
  textFont(font2);
  text("ㄇㄉㄈㄎ",50,250);
  
}



//week09_3_processing_sound import processing.sound.*; SoundFile sound; void setup(){ size(500,500); sound = new SoundFile(this,"In Game Music.mp3"); sound.play(); sound.loop(); } void draw(){ }


//week09_3_processing_sound
import processing.sound.*;
SoundFile sound;

void setup(){
  size(500,500);
  sound = new SoundFile(this,"In Game Music.mp3");
  sound.play();
  sound.loop();
}
void draw(){

}




//week09_4_multiple_sound_files_keyPressed_stop_play import processing.sound.*; SoundFile sound1,sound2,hit; void setup(){ size(500,500); sound1 = new SoundFile(this,"In Game Music.mp3"); sound2 = new SoundFile(this,"Intro Song_Final.mp3"); hit = new SoundFile(this,"sword slash.mp3"); sound2.play(); } void draw(){ background(255); } void mousePressed(){ hit.play(); } void keyPressed(){ if(key=='1'){ sound2.stop(); sound1.play(); }else{ sound1.stop(); sound2.play(); } }

//week09_4_multiple_sound_files_keyPressed_stop_play
import processing.sound.*;
SoundFile sound1,sound2,hit;

void setup(){
  size(500,500);
  sound1 = new SoundFile(this,"In Game Music.mp3");
  sound2 = new SoundFile(this,"Intro Song_Final.mp3");
  hit = new SoundFile(this,"sword slash.mp3");
  sound2.play();
}
void draw(){
  background(255);
}
void mousePressed(){
  hit.play();
}
void keyPressed(){
  if(key=='1'){
    sound2.stop();
    sound1.play();
  }else{
    sound1.stop();
    sound2.play();
  }
}



//week09_5_keyboard_ninja PImage board; void setup(){ size(600,400); board = loadImage("board.png"); } float appleX=200,appleY=200,appleVX=3,appleVY=-30; void draw(){ background(board); fill(255,0,0); ellipse(appleX,appleY,80,80); appleX+=appleVX; appleY+=appleVY; appleVY+=0.98; if(appleX>600){ appleX = 100;appleY=500;appleVX=5;appleVY=-30; } }



//week09_5_keyboard_ninja
PImage board;
void setup(){
  size(600,400);
  board = loadImage("board.png");
}
float appleX=200,appleY=200,appleVX=3,appleVY=-30;
void draw(){
  background(board);
  fill(255,0,0);
  ellipse(appleX,appleY,80,80);
  appleX+=appleVX;
  appleY+=appleVY;
  appleVY+=0.98;
  if(appleX>600){
    appleX = 100;appleY=500;appleVX=5;appleVY=-30;
  }
}



//week09_6_keyboard_ninja PImage board; void setup(){ size(600,400); board = loadImage("board.png"); } float appleX=100,appleY=500,appleVX=5,appleVY=-30; void randomApple(){ appleX=random(100,500); appleY=500; appleVX=random(8,-8); appleVY=random(-30,-20); } void draw(){ background(board); fill(255,0,0); ellipse(appleX,appleY,80,80); appleX+=appleVX; appleY+=appleVY; appleVY+=0.98; if(appleX>600 || appleX<0 || appleY>550){ randomApple(); } }


//week09_6_keyboard_ninja
PImage board;
void setup(){
  size(600,400);
  board = loadImage("board.png");
}
float appleX=100,appleY=500,appleVX=5,appleVY=-30;
void randomApple(){
  appleX=random(100,500);
  appleY=500;
  appleVX=random(8,-8);
  appleVY=random(-30,-20);
}
void draw(){
  background(board);
  fill(255,0,0);
  ellipse(appleX,appleY,80,80);
  appleX+=appleVX;
  appleY+=appleVY;
  appleVY+=0.98;
  if(appleX>600 || appleX<0 || appleY>550){
    randomApple();
  }
}





//week09_6_keyboard_ninja03_void_randomApple PImage board; void setup(){ size(600,400); board = loadImage("board.png"); randomApple(); } float appleX=100,appleY=500,appleVX=5,appleVY=-30; char appleKey; void randomApple(){ appleX=random(100,500); appleY=500; appleVX=random(8,-8); appleVY=random(-30,-20); appleKey=(char)('a'+int(random(26))); } int score=0; void draw(){ background(board); text("Score:"+score,400,50); fill(255,0,0); ellipse(appleX,appleY,80,80); fill(255,255,0); textSize(50); textAlign(CENTER,CENTER); text(appleKey,appleX,appleY); appleX+=appleVX; appleY+=appleVY; appleVY+=0.98; if(appleX>600 || appleX<0 || appleY>550){ randomApple(); } }
//week09_6_keyboard_ninja03_void_randomApple
PImage board;
void setup(){
  size(600,400);
  board = loadImage("board.png");
  randomApple();
}
float appleX=100,appleY=500,appleVX=5,appleVY=-30;
char appleKey;
void randomApple(){
  appleX=random(100,500);
  appleY=500;
  appleVX=random(8,-8);
  appleVY=random(-30,-20);
  appleKey=(char)('a'+int(random(26)));
}
int score=0;
void draw(){
  background(board);
  text("Score:"+score,400,50);
  fill(255,0,0);
  ellipse(appleX,appleY,80,80);
  fill(255,255,0);
  textSize(50);
  textAlign(CENTER,CENTER);
  text(appleKey,appleX,appleY);
  appleX+=appleVX;
  appleY+=appleVY;
  appleVY+=0.98;
  if(appleX>600 || appleX<0 || appleY>550){
    randomApple();
  }
}
















沒有留言:

張貼留言