下載以及安裝 Leap motion
小 Leap 真面目
*手需抬高大概十五公分左右
Leap Motion App Store
Leap motion 體驗
Open examples
因為沒加背景,導致畫面的重疊
模仿 example,再加上背景
開 reference 可以看到程式碼的功能
把 hand draw 拿掉
掉硬幣遊戲
- 程式碼
import de.voidplus.leapmotion.*;
LeapMotion leap;
void setup(){
size(640,480,P3D);
leap=new LeapMotion(this);
}
float coinX=320, 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);
}
- 成果
沒有留言:
張貼留言