打完程式碼後會出現 藍色網格
import de.voidplus.leapmotion.*;
PVector [][]fingerPosition = new PVector[5][10];
LeapMotion leap;
void setup(){
size(640,480,P3D);
leap = new LeapMotion(this);
for(int f=0;f<5;f++)for(int i=0;i<10;i++)fingerPosition[f][i]= new PVector(0,0,0);
}
void draw(){
background(255);
LeapmotionSetup();
drawFinger();
}
void LeapmotionSetup(){
int fps = leap.getFrameRate();
for(Hand hand : leap.getHands ()){
for(Finger finger : hand.getFingers()){
switch(finger.getType()){
case 0:
fingerPosition[0][0] = finger.getPosition();
break;
case 1:
fingerPosition[1][0] = finger.getPosition();
break;
case 2:
fingerPosition[2][0] = finger.getPosition();
break;
case 3:
fingerPosition[3][0] = finger.getPosition();
break;
case 4:
fingerPosition[4][0] = finger.getPosition();
break;
}
}
}
}
void drawFinger(){
for(int f=0;f<5;f++)
for(int i=9;i>0;i--){
fingerPosition[f][i].x = fingerPosition[f][i-1].x;
fingerPosition[f][i].y = fingerPosition[f][i-1].y;
fingerPosition[f][i].z = fingerPosition[f][i-1].z;
}
translate(width/2,height/2);
rotateY(radians(frameCount));
translate(-width/2,-height/2);
for(int f=0;f<5;f++)
for(int i=0;i<9;i++){
//strokeWeight(fingerPosition[f][i].z*30/50+1);
stroke(255,0,0,100-i*10);
line(fingerPosition[f][i+1].x,fingerPosition[f][i+1].y,fingerPosition[f][i+1].z,fingerPosition[f][i].x,fingerPosition[f][i].y,fingerPosition[f][i].z);
}
stroke(60,100,100);
for(int i=0;i<640;i+=20)
for(int j=0;j<480;j+=20){
noFill(); rect(i,j,20,20);
}
}
期中作品 我們想做一款利用體感互動的貪吃蛇(我和高健智同組)
1.利用LEAP手勢去更改方向
2.若是有研究出如何多方向性的貪吃蛇,會往這方向思考
意思是說不會想傳統只有上下左右的方向性,增加遊戲困難度和趣味性
沒有留言:
張貼留言