顯示具有 01160723_邱詠縉 標籤的文章。 顯示所有文章
顯示具有 01160723_邱詠縉 標籤的文章。 顯示所有文章

2015年6月29日 星期一

2015 kinect 期末作品-格鬥遊戲

01160723 邱詠縉
01160431劉冠逸

作品名稱 : 街頭快打


1.遊戲開始畫面:

2.偵測到右手後會有粉紅色小圓點


3.右手控制粉紅圓點
  一接觸到START上後會開始遊戲


4.   
   P1 人物偵測到後
   手的部位會有手套
   頭與身體會有紅色圖形區塊


5.
    深度偵測綠色部分為偵測到P2人物

6.
  P2 確定偵測後手、頭、身體也各有圖形覆蓋


PK !   FIGHT ! !


1.拳擊手套碰到對方紅色部位就會扣血


2.決戰到最後一滴血!!


3.最終勝利畫面  YEAH!!!!


       
DEMO影片



2015年5月25日 星期一

簡單賽車小遊戲
          //滑鼠控制角度
PImage imgCar;
float angle =0,dx=0,dy=0,vel=1;
void setup(){
  size(800,600,P3D);
  imgCar = loadImage("player_car.png");
}
void draw(){
  background(255);
  for(int i =-1;i<=8;i++){
    for(int j=-1;j<=6;j++){
      rect(i*100+dx%100,j*100+dy%100,100,100);
    }
  }
  pushMatrix();
    translate(width/2, height/2);
    rotateZ(angle);
    image(imgCar, -100,-100,200,200);
  popMatrix();
  dx=-vel*cos(angle);
  dy=-vel*sin(angle);
}
void mouseMoved(){
  int x=mouseX-pmouseX;
  int y=mouseY-pmouseY;
  if(x>0) angle+=1/40.0;
  if(x<0) angle-=1/40.0;
}
void keyPressed(){
  if(key=='l')angle++;
  if(key=='r')angle--;
  if(keyCode==UP)vel*=1.1;
  if(keyCode==DOWN)vel*=0.9;
}


FAAST


開啟FAAST.exe

加入New Gesture/Loop repeatedly


add 設定(loop repeatedly)

input 設定:      left hand /above /right hand /at least /20 /ok


output 設定:      add mouse move event /by relative distance /(1, 0) /ok


重複一次(方向要相反)

RUN!!







2015年5月18日 星期一

簡易的水果忍者


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); 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];
float fruitX=100, fruitY=400, fruitVX=4, fruitVY=-26;
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);
  //ellipse(fruitX,fruitY,50,50);
  for(int i=0; i<20; i++)
  {
    fruit[i].draw();
    fruit[i].update();
  }

  //fruitX+=fruitVX;
  //fruitY+=fruitVY;

  //fruitVY +=1.98
}

2015年5月11日 星期一

kinect

import SimpleOpenNI.*;
SimpleOpenNI openni;

void setup(){
  size(640,480);
  openni = new SimpleOpenNI(this);
  openni.enableRGB();
  openni.enableDepth();
  openni.enableUser();
}
void draw(){
 background(255);

 openni.update();

 image(openni.userImage(), 0, 0, 640, 480);

 int[] userList = openni.getUsers();
 for(int i=0;i<userList.length;i++)
 {
   PVector pos = new PVector();
   openni.getJointPositionSkeleton( userList[i], SimpleOpenNI.SKEL_LEFT_HIP, pos);
   println(pos);
   }
 }


抓頭部的位置放顆球

import SimpleOpenNI.*;
SimpleOpenNI openni;

void setup(){
  size(640,480);
  openni = new SimpleOpenNI(this);
  openni.enableRGB();
  openni.enableDepth();
  openni.enableUser();
}
void draw(){
 background(255);

 openni.update();

 image(openni.userImage(), 0, 0, 640, 480);

 int[] userList = openni.getUsers();
 for(int i=0;i<userList.length;i++)
 {
   if(openni.isTrackingSkeleton(userList[i])){
       PVector pos = new PVector();
       openni.getJointPositionSkeleton( userList[i], SimpleOpenNI.SKEL_HEAD, pos);
       println(pos); fill(255); ellipse(320+pos.x/3, 240-pos.y/3, 50, 50);
     }
   }
 }
 void onNewUser(SimpleOpenNI curContext, int userId)
 {
   curContext.startTrackingSkeleton(userId);
 }

2015年4月26日 星期日

期中作品 飛機吃硬幣

飛機吃硬幣
                                                   組員:
01160723 邱詠縉
01160431 劉冠逸




2015年3月16日 星期一

week3

邱詠縉、劉冠逸 同一組



劃出模擬直升機

畫出跟著手旋轉的地板

可以隨著手的高度旋轉上下移動,模擬出上下飛的感覺



import de.voidplus.leapmotion.*;
LeapMotion leap;
void setup() {
  size(800, 500, P3D);
   leap = new LeapMotion(this);
 }
 float nowX=0,nowY=0,nowA=0,nowZ=0;  
void draw() {  
  nowY+=10*cos(nowA); nowX+=10*sin(nowA);nowZ+=5*tan(nowA);
  background(255);
   for(int i=-10;i<=10;i++){
      for(int j=-10;j<=10;j++){
        pushMatrix();
          translate(300,300);
          rotateX(radians(70));
          rotateZ(nowA);
          translate(i*200+nowX,j*200+nowY,nowZ);
          fill(255);box(200);
        popMatrix();
      }      
    }
  for (Hand hand : leap.getHands ())
  {
    hand.draw();
    float angle = hand.getYaw();
    PVector pos = hand.getPosition();
    nowA += radians(-angle/40);
    translate(pos.x, pos.y, pos.z);
    rotateY(-radians(angle));
    fill(128);stroke(0);box(100);
    
   
  }

  
}

2015年3月9日 星期一

Week2

貼立體圖在手上

分別貼小球在各個手指


import de.voidplus.leapmotion.*;

LeapMotion leap;

void setup() {
  size(800, 500, P3D);
   leap = new LeapMotion(this);
 }

void draw() {
  background(255);
  for (Hand hand : leap.getHands ())
  {
    hand.draw();
    myDraw(hand.getPosition());
    myDraw(hand.getThumb().getPosition());
    myDraw(hand.getIndexFinger().getPosition());
    myDraw(hand.getMiddleFinger().getPosition());
    myDraw(hand.getRingFinger().getPosition());
    myDraw(hand.getPinkyFinger().getPosition());
  }
}
void myDraw(PVector pos)
{
  pushMatrix();
    translate(pos.x,pos.y);
    fill(255,0,0); sphere(20);
  popMatrix();
}


手的角度控制方塊旋轉

import de.voidplus.leapmotion.*;

LeapMotion leap;

void setup() {
  size(800, 500, P3D);
   leap = new LeapMotion(this);
 }
   
void draw() {
  background(255);
  for (Hand hand : leap.getHands ())
  {
    println("pitch:"+hand.getPitch());
    pushMatrix();
      translate(hand.getPosition().x,hand.getPosition().y+100);
      rotateZ(radians(hand.getPitch()) );
      rotateY(-radians(hand.getYaw()) );
      stroke(0); fill(255);box(100);
    popMatrix();
    
   
    
    hand.draw();
    myDraw(hand.getPosition());
    myDraw(hand.getThumb().getPosition());
    myDraw(hand.getIndexFinger().getPosition());
    myDraw(hand.getMiddleFinger().getPosition());
    myDraw(hand.getRingFinger().getPosition());
    myDraw(hand.getPinkyFinger().getPosition());
       
  }

  
}
void myDraw(PVector pos)
{
  pushMatrix();
    translate(pos.x,pos.y);
    fill(255,0,0); sphere(20);
  popMatrix();
}

Week2

貼立體圖在手上


分別貼小球在各個手指

import de.voidplus.leapmotion.*;

LeapMotion leap;

void setup() {
  size(800, 500, P3D);
   leap = new LeapMotion(this);
 }
 
void draw() {
  background(255);
  for (Hand hand : leap.getHands ())
  {
    hand.draw();
    myDraw(hand.getPosition());
    myDraw(hand.getThumb().getPosition());
    myDraw(hand.getIndexFinger().getPosition());
    myDraw(hand.getMiddleFinger().getPosition());
    myDraw(hand.getRingFinger().getPosition());
    myDraw(hand.getPinkyFinger().getPosition());
  }
}
void myDraw(PVector pos)
{
  pushMatrix();
    translate(pos.x,pos.y);
    fill(255,0,0); sphere(20);
  popMatrix();
}


手的角度控制方塊旋轉

import de.voidplus.leapmotion.*;

LeapMotion leap;

void setup() {
  size(800, 500, P3D);
   leap = new LeapMotion(this);
 }
 
void draw() {
  background(255);
  for (Hand hand : leap.getHands ())
  {
    println("pitch:"+hand.getPitch());
    pushMatrix();
      translate(hand.getPosition().x,hand.getPosition().y+100);
      rotateZ(radians(hand.getPitch()) );
      rotateY(-radians(hand.getYaw()) );
      stroke(0); fill(255);box(100);
    popMatrix();
 
 
 
    hand.draw();
    myDraw(hand.getPosition());
    myDraw(hand.getThumb().getPosition());
    myDraw(hand.getIndexFinger().getPosition());
    myDraw(hand.getMiddleFinger().getPosition());
    myDraw(hand.getRingFinger().getPosition());
    myDraw(hand.getPinkyFinger().getPosition());
     
  }


}
void myDraw(PVector pos)
{
  pushMatrix();
    translate(pos.x,pos.y);
    fill(255,0,0); sphere(20);
  popMatrix();
}

2015年3月2日 星期一

Week01_體驗體感遊戲





程式碼:

import de.voidplus.leapmotion.*;

LeapMotion leap;

void setup() {
  size(800, 500, OPENGL);
   leap = new LeapMotion(this);
}
void draw() {
  background(255);
  for (Hand hand : leap.getHands ())
  {
    hand.draw();
  }
}