2014年9月29日 星期一

01160492_張哲鳴, HW03, Week03,

import ddf.minim.*;
Minim minim;
AudioPlayer myMP3;

PImage img, img$, imgBG;
float eggX=750, eggY=550, eggVX, eggVY, flying=0;

void setup() {
  size(900, 600, P3D);
  minim=new Minim(this);
  myMP3=minim.loadFile("music.mp3");

  img=loadImage("iphone.png");
  img$=loadImage("money.png");
  imgBG = loadImage("apple.jpg");
  imgBG.resize(900, 600);
  imageMode(CENTER);
}

void draw() {
  background(imgBG);
  image(img, mouseX, mouseY, 300, 200);
  if (flying>0) {
    image(img$, eggX, eggY, 100, 100);
    eggX+=eggVX;
    eggY+=eggVY;
    flying--;
  }
}

void mousePressed(){
    myMP3.rewind();
    myMP3.play();
    eggX=400;
    eggY=0;
    flying=20;
    eggVX=(mouseX-eggX)/20;
    eggVY=(mouseY-eggY)/20;
  }


沒有留言:

張貼留言