2014年3月4日 星期二

week3黃柏勳

今天第一次demo
有跟一個學期前的自己比較起來覺得有進步,令人開心
下個禮拜的進度是開始用arduino板子接線來取代鍵盤的控制
希望可以有好的成果





程式碼://
PImage [] imgBird= new PImage[3];
PImage kk;
PImage bd;
PImage sd;
PImage sd2;
int showKK=0;
int showbd=0;
int showsd=0;
int showsd2=0;
PImage imgback;
int []sequence=new int[1000];
int birdN=0;//00,10,20
float birdY=100;
float birdVY=5;
int music=0;
import ddf.minim.*;
Minim minim;
AudioPlayer song;
AudioPlayer song2;
AudioPlayer song3;
AudioPlayer song4;
void setup() {
  imgback = loadImage("2.jpg");
  kk = loadImage("pp.png");
  bd = loadImage("3.png");
  sd = loadImage("4.png");
  sd2 = loadImage("sd2.png");
  minim = new Minim(this);
  song = minim.loadFile("hh.mp3");
  song2 = minim.loadFile("sd.mp3");
  song3 = minim.loadFile("bd.mp3");
  song4 = minim.loadFile("sn.mp3");
  if (music == 1) {
    song.play();
  }
  size(425, 600);
  PImage imgback;
  imgBird[0]=loadImage("bb.png");
  imgBird[1]=loadImage("bb2.png");
  imgBird[2]=loadImage("bb3.png");
}

void draw() {
  background(imgback);
  drawBird();
  if (showKK>0) {
    image(kk, 0, 0);
    showKK--;
  }
  if (showsd>0) {
    image(sd, 0, 0);
    showsd--;
  }
  if (showsd2>0) {
    image(sd2, 0, 0);
    showsd2--;
  }
  if (showbd>0) {
    image(bd, 0, 0);
    showbd--;
  }
}
void stop() {
  song.close();
  minim.stop();
  super.stop();
}
void drawBird() {
  image(imgBird[int(birdN/10)], 100, birdY);
  birdN=(birdN+1)%30;//changecolor

  // birdY+= birdVY;
  //  birdVY+=0.3;
  if (birdVY>10) birdVY=10;
}
void keyPressed() {
  if (key == 'a')
  {
    song.rewind();
    song.play();
    music=1;
    showKK=10;
  }
  if (key == 's')
  {
    song2.rewind();
    song2.play();
    music=1;
    showsd2=10;
  }
  if (key == 'g')
  {
    song2.rewind();
    song2.play();
    music=1;
    showsd=10;
  }
  if (key == 't')
  {
    song4.rewind();
    song4.play();
    music=1;
  }
  if (key == 'f')
  {
    song2.rewind();
    song2.play();
    music=1;
    showsd2=5;
  }
  if (key == 'b')
  {
    song3.rewind();
    song3.play();
    music=1;
    showbd=5;
  }
  if (key == 'n')
  {
    song3.rewind();
    song3.play();
    music=1;
    showbd=5;
  }
}
//


沒有留言:

張貼留言