顯示具有 01160474_黃雅平 標籤的文章。 顯示所有文章
顯示具有 01160474_黃雅平 標籤的文章。 顯示所有文章

2015年6月29日 星期一

期末作品展示

期末作品:水果DIY  黃雅平陳子軒 





說明:

本遊戲的構想來源是,由於暑假的到來,炎炎夏日氣溫飆高,

人人都想喝杯飲料冰品來降暑,但是珍珠奶茶之類的飲品味道又過於濃郁,

不如來杯清爽的現榨果汁,更能帶給自己涼爽的舒適氛圍。



操作:

左右手移動可以拿取水果放在果汁機中,放置好想榨的水果後,

左右手平舉並與肩同寬同高,然後兩手上下移動(註:上移須高過頭,

下移需低於頭),一段時間後,你的特製果汁就完成囉!



影片連結:




現榨過程:

(1) 開始畫面




(2) 身體晃動直到被Kinect偵測到




(3) 拿取想要的水果原料




(4) 移動到果汁機,水果便會自己跑進去等著被榨




(5) 開始榨果汁囉! 雙手平舉與肩同寬同高,頭上頭下的移動雙手






(6) 一段時間過後,你的果汁就榨好囉!










※還有一種隱藏版果汁等著你的嘗試喔!



程式說明(部分):

(1)匯入和宣告使用物件

import SimpleOpenNI.*;
import ddf.minim.*;
SimpleOpenNI ;
Minim ;
AudioPlayer ;
PImage ;

PVector ;

(2)建立視窗/物件

void setup(){

  size(640, 480);
  openni = new SimpleOpenNI(this);
  openni.enableDepth();
  openni.enableUser();
  minim = new Minim(this);
  playerBack = minim.loadFiIe("backmusic.mp3"); 
  imgHead = loadImage("head.PNG");


}

(3)預先給予變數初始值

float posAx = 30,  posAy = 20;
int nowA = 0;
int count = 0, number = 1;
int Lx = 0;
int Red = 0;

boolean check = true;

(4)實作重畫

void draw(){
  background(255);
  openni.update();
  image(imgBack, 0, 0, 640, 480);
  
  if(check == true) {
    int[] userList = openni.getUsers();
    for(int i=0; i<userList.length; i++){
      if(openni.isTrackingSkeleton(userList[i])){
        posL = new PVector();
        posR = new PVector();
        posHead = new PVector();
        openni.getJointPositionSkeleton(userList[i], SimpleOpenNI.SKEL_RIGHT_HAND,posR);
        openni.getJointPositionSkeleton(userList[i], SimpleOpenNI.SKEL_HEAD, posHead);
        posR.x = (int)posR.x/2+320;  posR.y = 240-(int)posR.y/2;
        image(imgHandR, posR.x, posR.y, 50, 50);
        image(imgHead, posHead.x-50, posHead.y, 150, 100);
        
        if(posL.x > posAx && posL.x < posAx+100 && posL.y > posAy && posL.y < posAy+80)             Move(true, false, false, false, false, false, false, false);
       
      }
    }
  }
  
  if(frameCount%30==0){   
    nowL = (int)random(2);
  }

  switch(nowK)
  {
     case 0: image(imgKl, posKx, posKy, 120, 90); break;
     case 1: image(imgKr, posKx, posKy, 120, 90); break;
  }
  switch(nowL)
  {
     case 0: image(imgLl, posLx, posLy, 130, 80); break;
     case 1: image(imgLr, posLx, posLy, 130, 80); break;
  }
  image(imgJ, 200, 60, 260, 260);
  
  if( Rx-Lx < 130 && Ry < Hy && Ly < Hy ) {
      if(number == 0) ;
    else { image(imgL3, 250, 180, 140, 140); Other++; if(Other==10) playerJuice.play();}
  }
  else if( Rx-Lx < 130 && Ry > Hy && Ly > Hy ) {
    if(count < 5) {
  
    }
    else { image(imgR3, 250, 180, 140, 140); Other++; if(Other==10) playerJuice.play(); 
  }
  
  else if(Other >= 100) { image(imgEndBomi, 120, 30, 400, 400); check = false; Other = 101; playerOK.play();}
  
  println(Orange, Green, Red, Other);

}

(5)使用函數讓code看起來精簡順暢

void Move(boolean lockedA, boolean lockedB, boolean lockedG, boolean lockedK, boolean lockedL, boolean lockedM, boolean lockedS, boolean lockedW) {
  if(lockedG) {
    if(posGx == 275 && posGy == 210);
    else {
       posGx = posL.x-65;  posGy = posL.y-50;  
       if(posGx > 200 && posGx < 380 && posGy > 60 && posGy < 250) {
         posGx = 275; posGy = 210; count++; number*=5;
         Move(false, false, false, false, false, false, false, false);
  }}}
  if(lockedK) {
    if(posKx == 275 && posKy == 220);
    else {
       posKx = posL.x-60;  posKy = posL.y-45;  
       if(posKx > 200 && posKx < 380 && posKy > 60 && posKy < 250) {
         posKx = 275; posKy = 220; count++; number*=7;
         Move(false, false, false, false, false, false, false, false);
  }}}
  if(lockedS) {
    if(posSx == 275 && posSy == 170);
    else {
       posSx = posR.x-55;  posSy = posR.y-55;  
       if(posSx > 200 && posSx < 380 && posSy > 60 && posSy < 250) {
         posSx = 275; posSy = 170; count++; number*=17;
         Move(false, false, false, false, false, false, false, false);
}

 void onNewUser(SimpleOpenNI curContext, int userId)
{
  curContext.startTrackingSkeleton(userId);

}

期末作業進度1---圖片設計

《期末作業進度1---圖片設計》

1.做遊戲背景:
我們的遊戲背景是充滿夏天氣息的海邊,
並且和本來就不能動的桌子跟水果機的下半部做結合。
所以其實桌子和水果機下半部是自己組合的。


---------------------------------------------------------------------------------------------

2.做水果攪拌時的圖片:
因為我們水果放進果汁機後,要進行攪拌,
攪拌時要有果汁的水在攪拌,
但又不能蓋住水果,
所以要加透明度。








因為要左右攪拌,所以分別作左右邊,也加透明度了。

------------------------------------------------------------------------------------

3.製作出的果汁種類:
我們分為三種果汁--->綠色,紅色,橘色
果汁的結果不是隨機的,
是經過一些搭配,有對應的結果。


綠色


橘色



紅色




但如果超過四樣水果,
會有隱藏版結果--->波蜜果菜汁。
這是健康的口味~~~哈哈

圖片全部都去背了。


---------------------------------------------------------------------------------------------------

4.手跟腳:
因為要偵測到手部(左手+右手)跟頭部,
在遊戲中是顯示出左手、右手、頭部的三種圖片。
但為了不失可愛又清爽的風格,
所以找的圖片非常符合本次風格。


頭部

右手



左手


是不是非常可愛啊~~~
圖片都已經去背了。

------------------------------------------------------------------------------------

5.遊戲音效:
音樂(1)遊戲背景音效想要有海邊海浪的拍打聲,
和夏威夷風格的音樂,
所以分別找了海浪拍打聲和夏威夷的一首歌
用威力導演將兩首歌接在一起
因此就有兩個混合的音樂囉。

音樂(2)遊戲結果的音效
就是果汁製作完成後的音效。


音樂當天DEMO再播放了。


2015年6月15日 星期一

期末作業的先前準備

《期末作業的先前準備》

1.準備許多水果圖片,並且去背完成










--------------------------------------------------------------------------------------------


2.自製背景:自己找圖片後,把它們合起來,
果汁機上部分需增加透明度,水果放進去才看的到在果汁機裡,
所以果汁機上下圖片需要分開。
以下的圖為基本底圖,意思是當背景。

3.把果汁機上半部變透明~~
方法是秘密。



期末構思

題目 : 水果DIY


夏天到了,覺得很熱很不舒服,
是否想來點清涼果汁來降火氣呢?
我們的期末作業構思,
將可以自製健康的果汁,
可以自由搭配選擇想要的水果,
製作出屬於自己的味道 !!

-------------------------------------------------------

遊戲過程 :

1.中間放置一台果汁機
2.兩旁有許多水果
3.左右手分別顯示兩個點,紅跟藍
4.把想要的水果拿到果汁機裡(最多三種水果)
5.跳10下,果汁機將啟動並開始攪拌
6.跳完後,果汁就完成了。

-------------------------------------------------------
遊戲結果 :

1.做出的飲料結果約有3.4種顏色
2.播放清爽的音樂


2015年5月25日 星期一

開車車


PImage imgCar;
float angle=0, dX=0, dY=0, vel=1;
void setup(){
imgCar = loadImage("car.png");
size(800, 600, P3D); }
for(int i=-1; i<=8; i++){
void draw(){ background(255);
rect(i*100+dX%100, j*100+dY%100, 100, 100);
for(int j=-1; j<=6; j++){ } } pushMatrix();
image(imgCar, -100, -50, 200, 100);
translate(width/2, height/2); rotateZ(angle); popMatrix();
int x = mouseX-pmouseX;
dX-=vel*cos(angle); dY-=vel*sin(angle); } void mouseMoved(){ int y = mouseY-pmouseY;
if(key=='l') angle++;
if(x>0) angle+=1/40.0; if(x<0) angle-=1/40.0; } void keyPressed(){ if(key=='r') angle--;
}
if(keyCode==UP) vel*=1.1; if(keyCode==DOWN) vel*=0.9;
println("vel:"+vel);

2015年5月18日 星期一

不是水果忍者的水果忍者

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+=0.68;
    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(X>0 && X<640 && Y>0 && Y<480 && openni.userImage().pixels[int(X)+int(Y)*640]==color(0, 0, 255)) 
      dead=true;    
  }
}
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)-5, -random(10));
}
void draw(){
  openni.update();
  image(openni.userImage(), 0, 0);
  
  for(int i=0; i<20; i++){
    fruit[i].draw();
    fruit[i].update();
  }
}

抓取頭部位置

抓取頭部位置

2015年5月4日 星期一

期中作品-鬥豆

介紹:
我們的期中作品是夾豆豆,圖檔資源是日本的一個網站"小柴豆"抓取的,
每個圖片都有去底,所以看起來就像豆豆在桌上一樣喔~~~
豆豆會隨機變換表情,夾起來也有特別的表情。

玩法:
必須在一定的時間內把六隻豆豆夾進碗裡,
手勢必須是食指和中指,像筷子一樣的動作,
也可以使用兩隻手,或者也可以兩個人一起夾。

勝利&失敗:
時間內6隻豆豆夾進碗裡就勝利,反之就失敗。

2015年3月23日 星期一

3D小畫家

可以用滑鼠畫出黑線,並且劃出的線會連續不斷
int []X=new int[1000];
int []Y=new int[1000];
int now=0;
void setup(){
  size(800,800,P3D);
}
void draw(){
  background(255);
  for(int i=1;i<now;i++){
    line(X[i],Y[i],X[i-1],Y[i-1]);
  }
}
void mouseDragged(){
  X[now]=mouseX;
  Y[now]=mouseY;
  now++;
}

2015年3月16日 星期一

方塊飛飛飛

方塊的左右轉會根據手的旋轉方向轉動唷!!


import de.voidplus.leapmotion.*;
LeapMotion leap;
void setup(){
  size(600, 600, P3D);
  leap = new LeapMotion(this);
}
void draw(){
  background(255);
  for(Hand hand : leap.getHands() ){
    hand.draw();
    float angle = hand.getYaw();   //抓手的左右轉
    PVector pos = hand.getPosition();  //抓手的位置
    translate(pos.x, pos.y, pos.z);  //讓方塊跟著手一起移動
    rotateY(-radians(angle));  //讓方塊跟著手一起轉動
    fill(128); stroke(255); box(100);  //stroke(0);線條是黑色
  }
}

地板會跟方塊反方向轉動


import de.voidplus.leapmotion.*;
LeapMotion leap;
void setup(){
  size(600, 600, P3D);
  leap = new LeapMotion(this);
}

float groundDir=0;
void draw(){
  background(255);
  for(int i=-10; i<=10; i++){
    for(int j=-10;j<=10; j++){
      pushMatrix();    //一直重劃
        translate(300, 300);    //地板位置
        rotateX(radians(70));   //向前面傾斜
        rotateZ(radians(groundDir));  //左右轉動是根據groundDir
        translate(i*30, j*30);   //下一個地板方塊的位置
        box(30);   //建地板方塊
      popMatrix();
    }
  }
  for(Hand hand : leap.getHands() ){
    hand.draw();
    float angle = hand.getYaw();
    PVector pos = hand.getPosition();
    translate(pos.x, pos.y, pos.z);
    rotateY(-radians(angle));
    fill(128); stroke(0); box(100);
    groundDir = -angle;   //groundDir的角度跟手相反
  }
}




import de.voidplus.leapmotion.*;
LeapMotion leap;
void setup(){
  size(600, 600, P3D);
  leap = new LeapMotion(this);
}

float nowX=0, nowY=0, nowA=0;  //左轉右轉前進
void draw(){
  background(255);
  nowY+=cos(nowA); nowX+=sin(nowA);   //左右旋轉角度
  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, 0);   //
        fill(255); box(200);
      popMatrix();
    }
  }
  for(Hand hand : leap.getHands() ){
    hand.draw();
    float angle = hand.getYaw();
    PVector pos = hand.getPosition();
    nowA += radians(-angle/40);    //nowA是地板左右旋轉的角度
    translate(pos.x, pos.y, pos.z);
    rotateY(-radians(angle));
    fill(128); stroke(0); box(100);
  }
}

2015年3月9日 星期一

掌控球+戴手套

import de.voidplus.leapmotion.*;
LeapMotion leap;
void setup(){
  size(600, 600, P3D);
  leap = new LeapMotion(this);
}
void draw(){
  background(255);
  for(Hand hand : leap.getHands() ){
    hand.draw();
    PVector pos = hand.getPosition();
    translate(pos.x, pos.y);
    fill(255, 0 ,0 ); box(100);
  }
}
import de.voidplus.leapmotion.*;
LeapMotion leap;
void setup(){
  size(600, 600, P3D);
  leap = new LeapMotion(this);
}
void draw(){
  background(255);
  for(Hand hand : leap.getHands() ){
    println("Yaw:" + hand.getYaw());
    pushMatrix();
      translate(300, 300);
      rotateY(hand.getYaw()*0.1);
      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_體驗體感遊戲和10行程式

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();
  }
}