2015年6月28日 星期日
week 13切水果
import SimpleOpenNI.*;
SimpleOpenNI openni;
class Fruit{
float X, Y, VX, VY;
boolean dead= false;
Fruit(float x, float y, float vx, float vy){
X=x; Y=y; VX=vx; VY=vy;
}
void draw(){
if(dead) fill(255, 0,0);
else fill(255);
ellipse(X, Y, 50, 50);
}
void update(){
X+=VX; Y+=VY; VY+=1.98;
if(X<-100||X>740||Y<-100||Y>580){
X=random(640); Y=random(240); VX=random(30)-15; VY=-random(30);
}
if (dist(X, Y, mouseX, mouseY)<50) dead=true;
if(X>0 && X<640 && Y>0 && Y<480 && openni.userImage().pixels[int(X)+int(Y)*640]==color (0,0,255)) dead=true;
}
}
void mouseMoved(){
strokeWeight(30); stroke(255, 0, 0); line(mouseX, mouseY, pmouseX, pmouseY);
strokeWeight(1); stroke(0);
}
Fruit fruit[]= new Fruit[20];
void setup(){
size(640, 480);
openni = new SimpleOpenNI(this);
openni.enableDepth();
openni.enableUser();
for (int i=0; i<20; i++){
fruit[i] = new Fruit(random(640), random(240), random(30)-15, -random(30));
}
}
void draw(){
openni.update();
image(openni.userImage(), 0, 0);
for (int i=0; i<20; i++){
fruit[i].draw();
fruit[i].update();
}
}
2015年6月15日 星期一
期末作業-進度
Let's share color!
構思
在Youtube找到影片:
2011大葉大學14屆視傳系形象長片-視界交互【點點人3主打】
https://www.youtube.com/watch?v=_8E6w0irTQE
https://www.youtube.com/watch?v=_8E6w0irTQE
看到這個影片產生了將它做成互動軟體的想法,偵測到人利用圓點印出,能多人一起使用,每個人都能有自己的顏色,並且能分享自己的顏色給對方
設計過程:
開始步驟:
- 如何印出點點人?
- 人如何有顏色?
- 如何互相變顏色?
步驟1.印出點點人
步驟2.人如何有顏色
先用矩陣宣告顏色
color[] userClr = new color[]{ color(255,0,0),
color(0,255,0),
color(0,0,255),
color(255,255,0),
color(255,0,255),
color(0,255,255)
};
將人物的點點填入顏色
blob_array[index] = 5; //矩陣裡六個顏色
//fill(GRAY); 這邊是原本還沒加入彩色時先令他為灰階
fill(userClr[ (userMap[index] - 1) % userClr.length ], 50); //填入顏色矩陣的色彩
預設第一人為紅色
偵測到第二個人
預設第二人為綠色
第三人為藍色,第四人為黃色,第五人為紫紅色,第六人為淡藍色。
步驟3.如何互相改變顏色?
Let's share color!
當紅色的人碰到綠色的人時,碰到的部分會變成紅色,慢慢地整個人會變成紅色。
當紅色的人不再接觸後,原本的綠色人會變成紅色,而原本紅色的人會變成下一個顏色。
這就是分享顏色!!!!!!!!
2015年5月18日 星期一
01160873_林瑋真
用滑鼠分割
發現被身體感應到的地方一樣可以
import SimpleOpenNI.*;
SimpleOpenNI openni;
float X, Y, VX, VY,split=0, angle=0;
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);
arc(X-split,Y,50,50,angle+PI,angle+PI*2, CHORD);
arc(X+split,Y,50,50,angle,angle+PI, CHORD);
}
else {fill(255);
if(X<-100||X>740||Y<-100||Y>580){
ellipse(X, Y, 50, 50);}
}
void update(){
if(dist(X,Y,mouseX,mouseY)<50){
X+=VX; Y+=VY; VY+=0.68;
X=random(640); Y=random(240); VX=random(10)-5; VY=-random(10); dead=false; split=0;
void mouseMoved(){
}
dead=true;
angle= atan2(mouseY-pmouseY,mouseX-pmouseX);
}
strokeWeight(30);stroke(255,0,0);line(mouseX,mouseY,pmouseX, pmouseY);
dead=true;
}
if(dead) split+=2;
}
}
strokeWeight(1);stroke(0);
}
openni.update();
Fruit fruit[] = new Fruit[20];
void setup(){
size(640,480);
openni = new SimpleOpenNI(this);
openni.enableDepth();
openni.enableUser();
fruit[i] = new Fruit(random(640),random(240),random(10)-5,-random(10));
for(int i=0;i<20;i++)
}
void draw(){
}
image(openni.userImage(),0,0);
for(int i=0;i<20;i++){
fruit[i].update();
fruit[i].draw();
}
發現error ,被分割過的球,又被分割一次了~
球只能分割一次-成功=)
import SimpleOpenNI.*;
SimpleOpenNI openni;
float X, Y, VX, VY,split=0, angle=0;
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);
arc(X-split,Y,50,50,angle+PI,angle+PI*2, CHORD);
arc(X+split,Y,50,50,angle,angle+PI, CHORD);
}
else {fill(255);
if(X<-100||X>740||Y<-100||Y>580){
ellipse(X, Y, 50, 50);}
}
void update(){
if(dead==false && dist(X,Y,mouseX,mouseY)<50){
X+=VX; Y+=VY; VY+=0.68;
X=random(640); Y=random(240); VX=random(10)-5; VY=-random(10); dead=false; split=0;
}
}
dead=true;
angle= atan2(mouseY-pmouseY,mouseX-pmouseX);
}
strokeWeight(30);stroke(255,0,0);line(mouseX,mouseY,pmouseX, pmouseY);
dead=true;
}
if(dead) split+=2;
}
void mouseMoved(){
void draw(){
strokeWeight(1);stroke(0);
}
Fruit fruit[] = new Fruit[20];
void setup(){
size(640,480);
openni = new SimpleOpenNI(this);
openni.enableDepth();
openni.enableUser();
fruit[i] = new Fruit(random(640),random(240),random(10)-5,-random(10));
for(int i=0;i<20;i++)
}
}
openni.update();
image(openni.userImage(),0,0);
for(int i=0;i<20;i++){
fruit[i].update();
fruit[i].draw();
}
week13
跳出很多水果球
import SimpleOpenNI.*;
SimpleOpenNI openni;
class Fruit {
float X, Y, VX, VY;
Fruit(float x, float y, float vx, float vy) {
X=x;
Y=y;
VX=vx;
VY=vy;
}
void draw() {
ellipse(X, Y, 50, 50);
}
void update() {
X+=VX;
Y+=VY;
VY+=1.98;
if (X<-100||X>740||Y<-100||Y>580) {
X=random(640);
Y=random(240);
VX=random(30)-15;
VY=-random(30);
}
}
}
Fruit fruit[]= new Fruit[20];
void setup() {
size(640, 480);
openni = new SimpleOpenNI(this);
openni.enableDepth();
openni.enableUser();
for (int i=0; i<20; i++)
fruit[i] = new Fruit(random(640), random(240), random(30)-15, -random(30));
}
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;
class Fruit {
float X, Y, VX, VY;
Fruit(float x, float y, float vx, float vy) {
X=x;
Y=y;
VX=vx;
VY=vy;
}
void draw() {
ellipse(X, Y, 50, 50);
}
void update() {
X+=VX;
Y+=VY;
VY+=1.98;
if (X<-100||X>740||Y<-100||Y>580) {
X=random(640);
Y=random(240);
VX=random(30)-15;
VY=-random(30);
}
}
}
Fruit fruit[]= new Fruit[20];
void setup() {
size(640, 480);
openni = new SimpleOpenNI(this);
openni.enableDepth();
openni.enableUser();
for (int i=0; i<20; i++)
fruit[i] = new Fruit(random(640), random(240), random(30)-15, -random(30));
}
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;
class Fruit {
float X, Y, VX, VY;
boolean dead = false;
Fruit(float x, float y, float vx, float vy) {
X=x;
Y=y;
VX=vx;
VY=vy;
dead=false;
}
void draw() {
if(dead) fill(255,0,0);
else fill(255);
ellipse(X, Y, 50, 50);
}
void update() {
X+=VX;
Y+=VY;
VY+=1.98;
if (X<-100||X>740||Y<-100||Y>580) {
X=random(640);
Y=random(240);
VX=random(30)-15;
VY=-random(30);
dead=false;
}
if(dist(X,Y,mouseX,mouseY)<50) dead=true;
}
}
void mouseMoved(){
strokeWeight(30); stroke(255,0,0); line(mouseX,mouseY,pmouseX,pmouseY);
strokeWeight(1); stroke(0);
}
Fruit fruit[]= new Fruit[20];
void setup() {
size(640, 480);
openni = new SimpleOpenNI(this);
openni.enableDepth();
openni.enableUser();
for (int i=0; i<20; i++)
fruit[i] = new Fruit(random(640), random(240), random(30)-15, -random(30));
}
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;
class Fruit {
float X, Y, VX, VY;
boolean dead = false;
Fruit(float x, float y, float vx, float vy) {
X=x;
Y=y;
VX=vx;
VY=vy;
dead=false;
}
void draw() {
if(dead) fill(255,0,0);
else fill(255);
ellipse(X, Y, 50, 50);
}
void update() {
X+=VX;
Y+=VY;
VY+=1.98;
if (X<-100||X>740||Y<-100||Y>580) {
X=random(640);
Y=random(240);
VX=random(30)-15;
VY=-random(30);
dead=false;
}
if(dist(X,Y,mouseX,mouseY)<50) dead=true;
if(X>0&&X<640&&Y>0&&Y<480&&openni.userImage().pixels[int(X)+int(Y)*640]==color(0,0,255)) dead=true;
}
}
void mouseMoved(){
strokeWeight(30); stroke(255,0,0); line(mouseX,mouseY,pmouseX,pmouseY);
strokeWeight(1); stroke(0);
}
Fruit fruit[]= new Fruit[20];
void setup() {
size(640, 480);
openni = new SimpleOpenNI(this);
openni.enableDepth();
openni.enableUser();
for (int i=0; i<20; i++)
fruit[i] = new Fruit(random(640), random(240), random(30)-15, -random(30));
}
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;
PImage imUser;
class Fruit {
float X, Y, VX, VY,split=0,angle=0;
boolean dead = false;
Fruit(float x, float y, float vx, float vy) {
X=x;
Y=y;
VX=vx;
VY=vy;
dead=false;
}
void draw() {
if(dead){ fill(255,0,0);
arc(X+split,Y,50,50,angle,angle+PI,CHORD);
arc(X-split,Y,50,50,angle+PI,angle+PI*2,CHORD);
}
else{ fill(255);ellipse(X, Y, 50, 50);}
}
void update() {
X+=VX/2;
Y+=VY/2;
VY+=0.5/2;
if (X<-100||X>740||Y<-100||Y>580) {
X=random(640);
Y=random(240);
VX=random(10)-15;
VY=-random(10);
dead=false;
split=0;
}
if(dead==false&&dist(X,Y,mouseX,mouseY)<50){
dead=true;
angle = atan2(mouseY-pmouseY,mouseX-pmouseX);
}
if(dead==false&&X>0 && X<640 &&Y>0 &&Y<480 &&openni.userImage().pixels[int(X)+int(Y)*640]==color(0,0,255)) {
dead=true;
}
if(dead) split+=2;
}
}
void mouseMoved(){
strokeWeight(30); stroke(255,0,0); line(mouseX,mouseY,pmouseX,pmouseY);
strokeWeight(1); stroke(0);
}
Fruit fruit[]= new Fruit[20];
void setup() {
size(640, 480);
openni = new SimpleOpenNI(this);
openni.enableDepth();
openni.enableUser();
for (int i=0; i<5; i++)
fruit[i] = new Fruit(random(640), random(240), random(10)-15, -random(10));
}
void draw() {
openni.update();
image(openni.userImage(), 0, 0);
for (int i=0; i<5; i++) {
fruit[i].draw();
fruit[i].update();
}
}
Week13
水果忍者partI
製作出許多水果
import SimpleOpenNI.*;
SimpleOpenNI openni;
class Fruit
{
float X,Y,VX,VY;
Fruit(float x,float y,float vx,float vy)
{
X=x;Y=y;VX=vx;VY=vy;
}
void draw()
{
ellipse(X,Y,50,50);
}
void update()
{
X+=VX;Y+=VY;VY+=1.98;
if(X<-100 || X>740 || Y<-100 || Y>580)
{
X=random(640);Y=random(240);VX=random(30)-15;VY=-random(30);
}
}
}
Fruit fruit[]=new Fruit[20];
void setup()
{
size(640,480);
openni=new SimpleOpenNI(this);
openni.enableDepth();
openni.enableUser();
for(int i=0;i<20;i++)
{
fruit[i]=new Fruit(random(640),random(240),random(30)-15,-random(30));
}
}
void draw()
{
openni.update();
image(openni.userImage(),0,0);
for(int i=0;i<20;i++)
{
fruit[i].draw();
fruit[i].update();
}
}
水果忍者partII
製作出刀鋒
import SimpleOpenNI.*;
SimpleOpenNI openni;
class Fruit
{
float X,Y,VX,VY;
boolean dead=false;
Fruit(float x,float y,float vx,float vy)
{
X=x;Y=y;VX=vx;VY=vy;dead=false;
}
void draw()
{
ellipse(X,Y,50,50);
}
void update()
{
X+=VX;Y+=VY;VY+=1.98;
if(X<-100 || X>740 || Y<-100 || Y>580)
{
X=random(640);Y=random(240);VX=random(30)-15;VY=-random(30);dead=false;
}
if(dist(X,Y,mouseX,mouseY)<50)
{
dead=true;
}
}
}
void mouseMoved()
{
strokeWeight(30);
stroke(255,0,0);
line(mouseX,mouseY,pmouseX,pmouseY);
strokeWeight(1);
stroke(0);
}
Fruit fruit[]=new Fruit[20];
void setup()
{
size(640,480);
openni=new SimpleOpenNI(this);
openni.enableDepth();
openni.enableUser();
for(int i=0;i<20;i++)
{
fruit[i]=new Fruit(random(640),random(240),random(30)-15,-random(30));
}
}
void draw()
{
openni.update();
image(openni.userImage(),0,0);
for(int i=0;i<20;i++)
{
fruit[i].draw();
fruit[i].update();
}
}
水果忍者partIII
製作切水果特效
水果忍者partVI
切水果囉
製作出許多水果
import SimpleOpenNI.*;
SimpleOpenNI openni;
class Fruit
{
float X,Y,VX,VY;
Fruit(float x,float y,float vx,float vy)
{
X=x;Y=y;VX=vx;VY=vy;
}
void draw()
{
ellipse(X,Y,50,50);
}
void update()
{
X+=VX;Y+=VY;VY+=1.98;
if(X<-100 || X>740 || Y<-100 || Y>580)
{
X=random(640);Y=random(240);VX=random(30)-15;VY=-random(30);
}
}
}
Fruit fruit[]=new Fruit[20];
void setup()
{
size(640,480);
openni=new SimpleOpenNI(this);
openni.enableDepth();
openni.enableUser();
for(int i=0;i<20;i++)
{
fruit[i]=new Fruit(random(640),random(240),random(30)-15,-random(30));
}
}
void draw()
{
openni.update();
image(openni.userImage(),0,0);
for(int i=0;i<20;i++)
{
fruit[i].draw();
fruit[i].update();
}
}
水果忍者partII
製作出刀鋒
SimpleOpenNI openni;
class Fruit
{
float X,Y,VX,VY;
boolean dead=false;
Fruit(float x,float y,float vx,float vy)
{
X=x;Y=y;VX=vx;VY=vy;dead=false;
}
void draw()
{
ellipse(X,Y,50,50);
}
void update()
{
X+=VX;Y+=VY;VY+=1.98;
if(X<-100 || X>740 || Y<-100 || Y>580)
{
X=random(640);Y=random(240);VX=random(30)-15;VY=-random(30);dead=false;
}
if(dist(X,Y,mouseX,mouseY)<50)
{
dead=true;
}
}
}
void mouseMoved()
{
strokeWeight(30);
stroke(255,0,0);
line(mouseX,mouseY,pmouseX,pmouseY);
strokeWeight(1);
stroke(0);
}
Fruit fruit[]=new Fruit[20];
void setup()
{
size(640,480);
openni=new SimpleOpenNI(this);
openni.enableDepth();
openni.enableUser();
for(int i=0;i<20;i++)
{
fruit[i]=new Fruit(random(640),random(240),random(30)-15,-random(30));
}
}
void draw()
{
openni.update();
image(openni.userImage(),0,0);
for(int i=0;i<20;i++)
{
fruit[i].draw();
fruit[i].update();
}
}
水果忍者partIII
製作切水果特效
import SimpleOpenNI.*;
SimpleOpenNI openni;
class Fruit
{
float X,Y,VX,VY;
boolean dead=false;
Fruit(float x,float y,float vx,float vy)
{
X=x;Y=y;VX=vx;VY=vy;dead=false;
}
void draw()
{
if(dead)fill(255,0,0);
else fill(255);
ellipse(X,Y,50,50);
}
void update()
{
X+=VX;Y+=VY;VY+=0.68;
if(X<-100 || X>740 || Y<-100 || Y>580)
{
X=random(640);Y=random(240);VX=random(10)-5;VY=-random(10);dead=false;
}
if(dist(X,Y,mouseX,mouseY)<50)
{
dead=true;
}
if(X>0 && X<640 && Y>0 && Y<480 &&openni.userImage().pixels[int(X)+int(Y)*640]==color(0,0,255))dead=true;
}
}
void mouseMoved()
{
strokeWeight(30);
stroke(255,0,0);
line(mouseX,mouseY,pmouseX,pmouseY);
strokeWeight(1);
stroke(0);
}
Fruit fruit[]=new Fruit[20];
void setup()
{
size(640,480);
openni=new SimpleOpenNI(this);
openni.enableDepth();
openni.enableUser();
for(int i=0;i<20;i++)
{
fruit[i]=new Fruit(random(640),random(240),random(30)-15,-random(30));
}
}
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;
PImage imUser;
class Fruit
{
float X,Y,VX,VY,split=0,angle=0;
boolean dead=false;
Fruit(float x,float y,float vx,float vy)
{
X=x;Y=y;VX=vx;VY=vy;dead=false;
}
void draw()
{
if(dead)
{
fill(255,0,0);
arc(X+split,Y,50,50,angle,angle+PI,CHORD);
arc(X-split,Y,50,50,angle+PI,angle+PI*2,CHORD);
}
else
{
fill(255);
ellipse(X,Y,50,50);
}
}
void update()
{
X+=VX;Y+=VY;VY+=0.68;
if(X<-100 || X>740 || Y<-100 || Y>580)
{
X=random(640);Y=random(240);VX=random(10)-5;VY=-random(10);dead=false;split=0;
}
if(dead==false && dist(X,Y,mouseX,mouseY)<50)
{
dead=true;
angle=atan2(mouseY-pmouseY,mouseX-pmouseX);
}
if(X>0 && X<640 && Y>0 && Y<480 &&openni.userImage().pixels[int(X)+int(Y)*640]==color(0,0,255))
{
dead=true;
}
if(dead)
{
split+=2;
}
}
}
void mouseMoved()
{
strokeWeight(30);
stroke(255,0,0);
line(mouseX,mouseY,pmouseX,pmouseY);
strokeWeight(1);
stroke(0);
}
Fruit fruit[]=new Fruit[20];
void setup()
{
size(640,480);
openni=new SimpleOpenNI(this);
openni.enableDepth();
openni.enableUser();
for(int i=0;i<20;i++)
{
fruit[i]=new Fruit(random(640),random(240),random(30)-15,-random(30));
}
}
void draw()
{
openni.update();
image(openni.userImage(),0,0);
for(int i=0;i<20;i++)
{
fruit[i].draw();
fruit[i].update();
}
}
WEEK13
下載
切水果
畫一直在拋的球
import SimpleOpenNI.*;
SimpleOpenNI openni;
class Fruit{
float X, Y, VX, VY;
Fruit(float x, float y, float vx, float vy){
X=x; Y=y; VX=vx; VY=vy;
}
void draw(){
ellipse(x, y, 50, 50);
}
void update(){
X+=VX;Y+=VY; VY+=1.98;
if(X<-100) || X>740 || Y<-100 || Y>580{
X=random(640); Y=random(240); VX=random(30)-15; VY=-random(30);
}
}
}
Fruit fruit[]= new Fruit[20];
void setup(){
size(640, 480);
openni= new SimpleOpenNI(this);
openni.enableDepth();
openni.enableUser();
for(int i=0; i<20; i++)
fruit[i]= new Fruit(random(640), random(240), random(30)-15, -random(30));
}
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;
class Fruit{
float X, Y, VX, VY;
boolean dead= false;
Fruit(float x, float y, float vx, float vy){
X=x; Y=y; VX=vx; VY=vy; dead= false;
}
void draw(){
if(dead) fill(255, 0 , 0);
else fill(255);
ellipse(X, Y, 50, 50);
}
void update(){
X+=VX;Y+=VY; VY+=1.98;
if(X<-100 || X>740 || Y<-100 || Y>580){
X=random(640); Y=random(240); VX=random(30)-15; VY=-random(30); dead= false;
}
if(dist(X, Y, mouseX, mouseY)<50) dead= true;
}
}
void mouseMoved(){
strokeWeight(30); stroke(255, 0, 0); line(mouseX, mouseY, pmouseX, pmouseY);
strokeWeight(1); stroke(0);
}
Fruit fruit[]= new Fruit[20];
void setup(){
size(640, 480);
openni= new SimpleOpenNI(this);
openni.enableDepth();
openni.enableUser();
for(int i=0; i<20; i++)
fruit[i]= new Fruit(random(640), random(240), random(30)-15, -random(30));
}
void draw(){
openni.update();
image(openni.userImage(), 0, 0);
for(int i=0; i<20; i++){
fruit[i].draw();
fruit[i].update();
}
}
利用Kinect,人去碰球變紅色
import SimpleOpenNI.*;
SimpleOpenNI openni;
class Fruit{
float X, Y, VX, VY;
boolean dead= false;
Fruit(float x, float y, float vx, float vy){
X=x; Y=y; VX=vx; VY=vy; dead= false;
}
void draw(){
if(dead) fill(255, 0 , 0);
else fill(255);
ellipse(X, Y, 50, 50);
}
void update(){
X+=VX;Y+=VY; VY+=1.98;
if(X<-100 || X>740 || Y<-100 || Y>580){
X=random(640); Y=random(240); VX=random(30)-15; VY=-random(30); dead= false;
}
if(dist(X, Y, mouseX, mouseY)<50) dead= true;
if(X>0 && X<640 && Y>0 && Y<480 && openni.userImage().pixels[int(X)+int(Y)*640]==color(0, 0, 255)) dead=true;
}
}
void mouseMoved(){
strokeWeight(30); stroke(255, 0, 0); line(mouseX, mouseY, pmouseX, pmouseY);
strokeWeight(1); stroke(0);
}
Fruit fruit[]= new Fruit[20];
void setup(){
size(640, 480);
openni= new SimpleOpenNI(this);
openni.enableDepth();
openni.enableUser();
for(int i=0; i<20; i++)
fruit[i]= new Fruit(random(640), random(240), random(30)-15, -random(30));
}
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;
class Fruit{
float X, Y, VX, VY;
boolean dead= false;
Fruit(float x, float y, float vx, float vy){
X=x; Y=y; VX=vx; VY=vy; dead= false;
}
void draw(){
if(dead) fill(255, 0 , 0);
else fill(255);
ellipse(X, Y, 50, 50);
}
void update(){
X+=VX;Y+=VY; VY+=1.98;
if(X<-100 || X>740 || Y<-100 || Y>580){
X=random(640); Y=random(240); VX=random(30)-15; VY=-random(30); dead= false;
}
if(dist(X, Y, mouseX, mouseY)<50) dead= true;
if(X>0 && X<640 && Y>0 && Y<480 && openni.userImage().pixels[int(X)+int(Y)*640]==color(0, 0, 255)) dead=true;
}
}
void mouseMoved(){
strokeWeight(30); stroke(255, 0, 0); line(mouseX, mouseY, pmouseX, pmouseY);
strokeWeight(1); stroke(0);
}
Fruit fruit[]= new Fruit[20];
void setup(){
size(640, 480);
openni= new SimpleOpenNI(this);
openni.enableDepth();
openni.enableUser();
for(int i=0; i<20; i++)
fruit[i]= new Fruit(random(640), random(240), random(30)-15, -random(30));
}
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;
class Fruit{
float X, Y, VX, VY, split=0, angle=0;
boolean dead= false;
Fruit(float x, float y, float vx, float vy){
X=x; Y=y; VX=vx; VY=vy; dead= false;
}
void draw(){
if(dead){
fill(255, 0, 0);
arc(X+split, Y, 50, 50, angle, angle+PI, CHORD);
arc(X-split, Y, 50, 50, angle+PI, angle+PI*2, CHORD);
}
else {
fill(255);
ellipse(X, Y, 50, 50);
}
}
void update(){
X+=VX; Y+=VY; VY+=0.68;
if(X<-100 || X>740 || Y<-100 || Y>580){
X=random(640); Y=random(240); VX=random(10)-15; VY=-random(10); dead= false; split=0;
}
if(dead==false && dist(X, Y, mouseX, mouseY)<50){
dead= true;
angle= atan2(mouseY-pmouseY, mouseX-pmouseX);
}
if(dead==false && X>0 && X<640 && Y>0 && Y<480 && openni.userImage().pixels[int(X)+int(Y)*640]==color(0, 0, 255)){
dead=true;
}
if(dead) split+=2;
}
}
void mouseMoved(){
strokeWeight(30); stroke(255, 0, 0); line(mouseX, mouseY, pmouseX, pmouseY);
strokeWeight(1); stroke(0);
}
Fruit fruit[]= new Fruit[20];
void setup(){
size(640, 480);
openni= new SimpleOpenNI(this);
openni.enableDepth();
openni.enableUser();
for(int i=0; i<20; i++)
fruit[i]= new Fruit(random(640), random(240), random(10)-15, -random(10));
}
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;
class Fruit{
float X, Y, VX, VY, split=0, angle=0;
boolean dead= false;
Fruit(float x, float y, float vx, float vy){
X=x; Y=y; VX=vx; VY=vy; dead= false;
}
void draw(){
if(dead){
fill(255, 0, 0);
arc(X+split, Y, 50, 50, angle, angle+PI, CHORD);
arc(X-split, Y, 50, 50, angle+PI, angle+PI*2, CHORD);
}
else {
fill(255);
ellipse(X, Y, 50, 50);
}
}
void update(){
X+=VX; Y+=VY; VY+=0.68;
if(X<-100 || X>740 || Y<-100 || Y>580){
X=random(640); Y=random(240); VX=random(10)-15; VY=-random(10); dead= false; split=0;
}
if(dead==false && dist(X, Y, mouseX, mouseY)<50){
dead= true;
angle= atan2(mouseY-pmouseY, mouseX-pmouseX);
}
if(dead==false && X>0 && X<640 && Y>0 && Y<480 && openni.userImage().pixels[int(X)+int(Y)*640]==color(0, 0, 255)){
dead=true;
}
if(dead) split+=2;
}
}
void mouseMoved(){
strokeWeight(30); stroke(255, 0, 0); line(mouseX, mouseY, pmouseX, pmouseY);
strokeWeight(1); stroke(0);
}
Fruit fruit[]= new Fruit[20];
void setup(){
size(640, 480);
openni= new SimpleOpenNI(this);
openni.enableDepth();
openni.enableUser();
for(int i=0; i<20; i++)
fruit[i]= new Fruit(random(640), random(240), random(10)-15, -random(10));
}
void draw(){
openni.update();
image(openni.userImage(), 0, 0);
for(int i=0; i<20; i++){
fruit[i].draw();
fruit[i].update();
}
}
訂閱:
文章 (Atom)
































