還須修改部分幫主角去背和調整
leap 不太靈敏可能還需要修改等等
以下為程式碼 :
import de.voidplus.leapmotion.*;
LeapMotion leap;
PImage a;
PImage b;
PImage c;
PImage d;
PVector [] geek=new PVector[5];
PVector [] m=new PVector[5];
float [] vgeek=new float[5];
boolean [] coin=new boolean[5];
boolean gameover= true;
float x=0,x1=900,y=0,vy=0;
int score=0,gg;
void setup() {
a=loadImage("123.png");
b=loadImage("456.png");
c=loadImage("789.png");
d=loadImage("coin.png");
size(900,500);
for(int i=0;i<3;i++){
geek[i]=new PVector(random(1000,1200), 400);
}
for(int i=0;i<5;i++){
m[i]=new PVector(1000, random(i*300));
vgeek[i]=random(8);
coin[i]=true;
}
leap = new LeapMotion(this).withGestures();
}
void draw() {
image(b,x,0,900,500);
image(b,x1,0,900,500);
x-=10;
x1-=10;
if(x<=-900){
x=900;
}
if(x1<=-900){
x1=900;
}
image(a,0,y,100,100);
y+= vy;
if(y<300){
vy+=0.7;
}
if(y>400){
y=400;
}
if(y<0){
y+=10;
}
for(int i=0;i<3;i++){
image(c,geek[i].x,400,100,100);
geek[i].x-=vgeek[i];
if(geek[i].x<=10){
geek[i].x=1000;
vgeek[i]=random(5,10);
}
}
for(int i=0;i<5;i++){
if(coin[i]==true){
image(d,m[i].x, m[i].y, 60, 60);}
m[i].x-=5;
if(m[i].x<=-1000){
m[i].x=(random(1000,1500));
m[i].y=(random(300));
coin[i]=true;
}
}
for(int i=0;i<3;i++){
if(dist(0+50,y+50,geek[i].x+50,450)<100){
background(0);
gameover = false;
}
}
for(int i=0;i<5;i++){
if(dist(0+50,y+50,m[i].x+30,m[i].y+30)<80 && coin[i]==true){
score += 1;
coin[i] = false;
}
}
textSize(50);
text("Score: "+score,600,100);
if(gameover==false){
background(0);
textSize(100);
text("GameOver ",200,250);
}
}
void leapOnScreenTapGesture(ScreenTapGesture g){
int id = g.getId();
//Finger finger = g.getFinger();
PVector position = g.getPosition();
PVector direction = g.getDirection();
long duration = g.getDuration();
float duration_seconds = g.getDurationInSeconds();
vy =-15;
}
/*void mousePressed(){
vy = -10;
}
*/
沒有留言:
張貼留言