2016年11月3日 星期四

20161103 小楓兒筆記


leap motion

準備開箱



















leap motion 真面目






















實作

leap motion讀取手





import de.voidplus.leapmotion.*;
LeapMotion leap;
void setup(){
  size(640,480);
  leap=new LeapMotion(this);
}
void draw(){
  background(255);
  for(Hand hand:leap.getHands()){
    hand.draw();
  }
}



*可以找到所有超連結功能
processing→libraries→LeapMotionForProcessing→reference




接金幣





顯示版

隱藏版








































import de.voidplus.leapmotion.*;
LeapMotion leap;
void setup(){
  size(640,480,P3D);
  leap=new LeapMotion(this);
}
float coinX=240,coinY=0,coinVX=0,coinVY=3;
int score=0;
void draw(){
  background(255);
  coinY+=coinVY;
  fill(255,255,0);ellipse(coinX,coinY,60,60);
  if(coinY>480){
    coinY=0;
    coinX=random(640);
  }
  for(Hand hand:leap.getHands()){
    hand.draw();  ←隱藏這行可以不顯示手
    PVector pos=hand.getPosition();
    println(pos);
    fill(255,0,0);ellipse(pos.x,pos.y,100,100);
    if(dist(pos.x,pos.y,coinX,coinY)<100){
      score+=10;
      coinY=0;
      coinX=random(640);
    }
  }
  fill(0,255,0);
  textSize(50);
  text("Score:"+score,400,100);
}

沒有留言:

張貼留言