飛出很多水果
import SimpleOpenNI.*;
SimpleOpenNI openni;
float X, Y, VX, VY;
class Fruit{
Fruit(float x, float y,float vx, float vy){
X=x; Y=x; VX=vx; VY=vy;
}
void draw(){
X+=VX; Y+=VY; VY+=1.98;
ellipse(X, Y, 50, 50);
}
void update(){
X=random(640); Y=random(240); VX=random(30)-15; VY=-random(30);
if(X<-100||X>740||Y<-100||Y>580){
}
}
}
openni.enableDepth();
Fruit fruit[] = new Fruit[20];
void setup(){
size(640,480);
openni = new SimpleOpenNI(this);
openni.enableUser();
fruit[i] = new Fruit(random(640),random(240),random(30)-15,-random(30));
for(int i=0;i<20;i++)
}
void draw(){
openni.update();
image(openni.userImage(),0,0);
}
for(int i=0;i<20;i++){
fruit[i].draw();
fruit[i].update();
}
測試:碰到藍色畫面也會變紅
用滑鼠滑動,死掉變為紅色
import SimpleOpenNI.*;
SimpleOpenNI openni;
float X, Y, VX, VY;
class Fruit{
Fruit(float x, float y,float vx, float vy){
boolean dead = false;
X=x; Y=x; VX=vx; VY=vy; dead=false;
}
void draw(){
if(dead) fill(255,0,0);
void update(){
else fill(255);
ellipse(X, Y, 50, 50);
}
X=random(640); Y=random(240); VX=random(30)-15; VY=-random(30); dead=false;
X+=VX; Y+=VY; VY+=1.98;
if(X<-100||X>740||Y<-100||Y>580){
}
strokeWeight(30);stroke(255,0,0);line(mouseX,mouseY,pmouseX, pmouseY);
if(dist(X,Y,mouseX,mouseY)<50) dead=true;
}
}
void mouseMoved(){
openni.enableDepth();
strokeWeight(1);stroke(0);
}
Fruit fruit[] = new Fruit[20];
openni = new SimpleOpenNI(this);
void setup(){
size(640,480);
openni.update();
openni.enableUser();
for(int i=0;i<20;i++)
fruit[i] = new Fruit(random(640),random(240),random(30)-15,-random(30));
}
void draw(){
}
image(openni.userImage(),0,0);
for(int i=0;i<20;i++){
fruit[i].update();
fruit[i].draw();
}
import SimpleOpenNI.*;
SimpleOpenNI openni;
float X, Y, VX, VY;
class Fruit{
Fruit(float x, float y,float vx, float vy){
boolean dead = false;
X=x; Y=x; VX=vx; VY=vy; dead=false;
}
void draw(){
if(dead) fill(255,0,0);
void update(){
else fill(255);
ellipse(X, Y, 50, 50);
}
X=random(640); Y=random(240); VX=random(10)-5; VY=-random(10); dead=false;
X+=VX; Y+=VY; VY+=0.68;
if(X<-100||X>740||Y<-100||Y>580){
}
if(X>0 && X<640 && Y>0 && Y<480 && openni.userImage().pixels[int(X)+int(Y)*640]==color(0,0,255)) dead=true;
if(dist(X,Y,mouseX,mouseY)<50) dead=true;
}
}
void mouseMoved(){
Fruit fruit[] = new Fruit[20];
strokeWeight(30);stroke(255,0,0);line(mouseX,mouseY,pmouseX, pmouseY);
strokeWeight(1);stroke(0);
}
void setup(){
size(640,480);
fruit[i] = new Fruit(random(640),random(240),random(30)-15,-random(30));
openni = new SimpleOpenNI(this);
openni.enableDepth();
for(int i=0;i<20;i++)
openni.enableUser();
}
void draw(){
}
openni.update();
image(openni.userImage(),0,0);
fruit[i].draw();
for(int i=0;i<20;i++){
fruit[i].update();
}




沒有留言:
張貼留言