期末作品:鐵殺雞之打雞戰士
組員:張開為
2016年5月12日 星期四
2016年3月24日 星期四
Week05 02160995_何杰璋
一.眼珠轉動
void setup(){
size(120,100);
}
void draw(){
float t=frameCount/180.0*PI;
background(0);
fill(255);
ellipse(40,50,33,33);
ellipse(120-40,50,33,33);
fill(0);
ellipse(40+15*cos(t),50+15*sin(t),5,5);
ellipse(120-40+15*cos(t),50+15*sin(t),5,5);
}
size(120,100);
}
void draw(){
float t=frameCount/180.0*PI;
background(0);
fill(255);
ellipse(40,50,33,33);
ellipse(120-40,50,33,33);
fill(0);
ellipse(40+15*cos(t),50+15*sin(t),5,5);
ellipse(120-40+15*cos(t),50+15*sin(t),5,5);
}
二.眼珠跟著滑鼠動,會有鬥雞眼
void setup(){
size(320,300);
}
void draw(){
//float t=frameCount/180.0*PI;
background(0);
fill(255);
ellipse(40,50,33,33);
ellipse(120-40,50,33,33);
fill(0);
float t=atan2(mouseY-50,mouseX-45);
ellipse(40+15*cos(t),50+15*sin(t),5,5);
t=atan2(mouseY-50,mouseX-(120-40));
ellipse(120-40+15*cos(t),50+15*sin(t),5,5);
}
size(320,300);
}
void draw(){
//float t=frameCount/180.0*PI;
background(0);
fill(255);
ellipse(40,50,33,33);
ellipse(120-40,50,33,33);
fill(0);
float t=atan2(mouseY-50,mouseX-45);
ellipse(40+15*cos(t),50+15*sin(t),5,5);
t=atan2(mouseY-50,mouseX-(120-40));
ellipse(120-40+15*cos(t),50+15*sin(t),5,5);
}
三.雙螺旋
void setup(){
size(600,600);
}
void draw(){
background(255);
float t=frameCount/100.0;
for(float f=0;f<PI;f+=0.1){
rect(200+150*cos(f+t),f*100,30,30);
rect(200+150*cos(f+t+PI),f*100,30,30);
}
}
2016年3月17日 星期四
Week 04 02160995_何杰璋
今天小小遲到哩^_^
下次注意!!!!!!!!!!!!!
本次上課內容:
期中作品需求
1.射擊
2.打棒球
import de.voidplus.leapmotion.*;
LeapMotion leap;
void setup(){
size(600,400);
leap=new LeapMotion(this);
}
void draw(){
background(255);
for(Hand hand:leap.getHands()){ //作射擊需要先找到食指的位置
Finger finger_index=hand.getIndexFinger();
finger_index.draw();
}
}
import de.voidplus.leapmotion.*;
LeapMotion leap;
void setup(){
size(600,400,P3D); //畫出3D的模型
leap=new LeapMotion(this);
}
void draw(){
background(255);
for(Hand hand:leap.getHands()){
Finger finger_index=hand.getIndexFinger();
finger_index.draw();
PVector pos=finger_index.getPosition(); //位置
PVector dir=finger_index.getDirection(); //方向
println(pos);
println(dir);
}
lights(); //
fill(255,0,0);
translate(width/2,height/2); //左上角當中心畫在畫面正中央
rotateY(radians(frameCount)); //用radians把frameCount轉換成"度"
box(300,100,100);
}
import de.voidplus.leapmotion.*;
LeapMotion leap;
void setup(){
size(600,400,P3D);
leap=new LeapMotion(this);
}
PVector pos=null,dir=null;
void draw(){
background(255);
for(Hand hand:leap.getHands()){
Finger finger_index=hand.getIndexFinger();
finger_index.draw();
pos=finger_index.getPosition();
dir=finger_index.getDirection();
//println(pos);
//println(dir);
}
lights();
fill(255,0,0);
pushMatrix();
translate(width/2,height/2);
for(int i=0;i<10;i++){
if(dir!=null) translate(dir.x*10*i,dir.y*10*i,dir.z*10*i);
sphere(40);
}
popMatrix();
//rotateY(radians(frameCount));
//box(300,100,100);
}
LeapMotion leap;
void setup(){
size(600,400,P3D);
leap=new LeapMotion(this);
}
PVector pos=null,dir=null;
void draw(){
background(255);
for(Hand hand:leap.getHands()){
Finger finger_index=hand.getIndexFinger();
finger_index.draw();
pos=finger_index.getPosition();
dir=finger_index.getDirection();
//println(pos);
//println(dir);
}
lights();
fill(255,0,0);
pushMatrix();
translate(width/2,height/2);
for(int i=0;i<10;i++){
if(dir!=null) translate(dir.x*10*i,dir.y*10*i,dir.z*10*i);
sphere(40);
}
popMatrix();
//rotateY(radians(frameCount));
//box(300,100,100);
}
import de.voidplus.leapmotion.*;
PVector pos=null,dir=null;
PVector []bullet=new PVector[10]; //10顆子彈
PVector []bullet_dir=new PVector[10]; //10顆子彈的向量
int bulletNow=0;
LeapMotion leap;
void setup(){
size(600,400,P3D);
leap=new LeapMotion(this);
for(int i=0;i<10;i++){
bullet[i]=new PVector(0,0,0);
bullet_dir[i]=new PVector(0,0,0);
}
}
void draw(){
background(255);
for(Hand hand:leap.getHands()){
Finger finger_index=hand.getIndexFinger();
finger_index.draw();
//pos=finger_index.getPosition();
dir=finger_index.getDirection();
//println(pos);
//println(dir);
}
lights();
fill(255,0,0);
translate(width/2,height/2);
pushMatrix();
for(int i=0;i<10;i++){
if(dir!=null) translate(dir.x*10*i,dir.y*10*i,dir.z*10*i);
sphere(40);
}
popMatrix();
pushMatrix();
fill(0,0,255);
for(int i=0;i<10;i++){
pushMatrix();
translate(bullet[i].x,bullet[i].y,bullet[i].z);
sphere(41);
bullet[i].x+=bullet_dir[i].x;
bullet[i].y+=bullet_dir[i].y;
bullet[i].z+=bullet_dir[i].z;
popMatrix();
}
popMatrix();
}
void keyPressed(){ //按按鍵發射
PVector pos=null,dir=null;
PVector []bullet=new PVector[10]; //10顆子彈
PVector []bullet_dir=new PVector[10]; //10顆子彈的向量
int bulletNow=0;
LeapMotion leap;
void setup(){
size(600,400,P3D);
leap=new LeapMotion(this);
for(int i=0;i<10;i++){
bullet[i]=new PVector(0,0,0);
bullet_dir[i]=new PVector(0,0,0);
}
}
void draw(){
background(255);
for(Hand hand:leap.getHands()){
Finger finger_index=hand.getIndexFinger();
finger_index.draw();
//pos=finger_index.getPosition();
dir=finger_index.getDirection();
//println(pos);
//println(dir);
}
lights();
fill(255,0,0);
translate(width/2,height/2);
pushMatrix();
for(int i=0;i<10;i++){
if(dir!=null) translate(dir.x*10*i,dir.y*10*i,dir.z*10*i);
sphere(40);
}
popMatrix();
pushMatrix();
fill(0,0,255);
for(int i=0;i<10;i++){
pushMatrix();
translate(bullet[i].x,bullet[i].y,bullet[i].z);
sphere(41);
bullet[i].x+=bullet_dir[i].x;
bullet[i].y+=bullet_dir[i].y;
bullet[i].z+=bullet_dir[i].z;
popMatrix();
}
popMatrix();
}
void keyPressed(){ //按按鍵發射
bullet[bulletNow].x=0; bullet[bulletNow].y=0; bullet[bulletNow].z=0; //排除超過10顆子彈會當機的問題
bullet_dir[bulletNow].x=dir.x*5; //子彈速度
bullet_dir[bulletNow].y=dir.y*5;
bullet_dir[bulletNow].z=dir.z*5;
bulletNow++;
bullet_dir[bulletNow].x=dir.x*5; //子彈速度
bullet_dir[bulletNow].y=dir.y*5;
bullet_dir[bulletNow].z=dir.z*5;
bulletNow++;
if(bulletNow>=10){
bulletNow=0;
//rotateY(radians(frameCount));
//box(300,100,100);
}
bulletNow=0;
//rotateY(radians(frameCount));
//box(300,100,100);
}
import de.voidplus.leapmotion.*;
LeapMotion leap;
PVector pos,dir,ball;
void setup() {
size(600, 400,P3D);
leap = new LeapMotion(this);
pos = new PVector(300,200,0); ball=new PVector(0,0,0);
}
void draw(){
ball.x+=2; ball.y+=2;
for(Hand hand : leap.getHands()){
pos = hand.getPosition();
}
background(255);
fill(255,0,0);
pushMatrix();
translate(pos.x,pos.y,pos.z);
box(30,30,30);
popMatrix();
pushMatrix();
translate(ball.x,ball.y);
sphere(30);
if(dist(ball.x,ball.y,pos.x,pos.y)<30) background(255.,0.0);
popMatrix();
}
2016年3月10日 星期四
Week03 02160995_何杰璋
延續上禮拜講過的
用手指畫出各種顏色的線條
並讓手指頭可以進行3D立體旋轉來畫畫
以下為程式碼^_^
LeapMotion leap;
PVector [][] pt = new PVector[5][50];
//PVector pt1,pt2,pt3,pt4,pt5,pt6,pt7,pt8,pt9,pt10;
void setup(){
size(640,480,P3D);
colorMode(HSB, 100);
for(int f=0;f<5;f++)
for(int i=0;i<50;i++)
pt[f][i] = new PVector(0,0,0);
leap = new LeapMotion(this);//LeapMotion起始值
}
void draw(){
background(0);
//stroke(48,191,153);
stroke(#30BF99);
for(int f=0;f<5;f++)
for(int i=49;i>0;i--){pt[f][i].x=pt[f][i-1].x;pt[f][i].y=pt[f][i-1].y;}
for(Hand hand : leap.getHands()){//抓取手
for(Finger finger : hand.getFingers()){//抓取手指
int f=finger.getType();
PVector now = finger.getPosition();
pt[f][0].x = now.x;
pt[f][0].y = now.y;
}
}
for(int f=0;f<5;f++){
stroke(f*20, 100,100);
for(int i=1;i<10;i++)
line(pt[f][i].x,pt[f][i].y,pt[f][i].z,pt[f][i-1].x,pt[f][i-1].y,pt[f][i-1].z);
}
}
在3D空間中畫出顏色線條
import de.voidplus.leapmotion.*;//LeapMotion標頭檔
LeapMotion leap;
PVector [][] pt = new PVector[5][50];
//PVector pt1,pt2,pt3,pt4,pt5,pt6,pt7,pt8,pt9,pt10;
void setup(){
size(640,480,P3D);
colorMode(HSB, 100);
for(int f=0;f<5;f++)
for(int i=0;i<50;i++)
pt[f][i] = new PVector(0,0,0);
leap = new LeapMotion(this);//LeapMotion起始值
}
void draw(){
background(0);
//stroke(48,191,153);
stroke(#30BF99);
for(int f=0;f<5;f++)
for(int i=49;i>0;i--){pt[f][i].x=pt[f][i-1].x;pt[f][i].y=pt[f][i-1].y;pt[f][i].z=pt[f][i-1].z;}
for(Hand hand : leap.getHands()){//抓取手
for(Finger finger : hand.getFingers()){//抓取手指
int f=finger.getType();
PVector now = finger.getPosition();
pt[f][0].x = now.x;
pt[f][0].y = now.y;
pt[f][0].z = now.z*2-90;
if(f==1) println(now);
}
}
translate(width/2,height/2,0);
rotateY(radians(frameCount/4.0));
translate(-width/2,-height/2,0);
for(int f=0;f<5;f++){
for(int i=1;i<50;i++){
stroke(f*20, 100,100);
line(pt[f][i].x,pt[f][i].y,pt[f][i].z,pt[f][i-1].x,pt[f][i-1].y,pt[f][i-1].z);
}
}
stroke(60,100,100);
for(int i=0;i<640;i+=20)
for(int j=0;j<480;j+=20){
noFill();rect(i,j,20,20);
}
}
期中作品:
利用點擊和抓取方式來遊玩的「殭屍獵手」射擊遊戲^_^
2016年2月25日 星期四
Week 01 02160995_何杰璋
加入FB社團 ─「2016體感互動」
1. Processing 解壓/執行
2. Sketch-ImportLibrary 找Leap Motion for Processing
3. 安裝好後,File-Examples,ImportLibrary
4. 找 Leap Motion 範例
5. 收 email,接受邀請Blog,寫Blog
這學期體感互動的第一堂課
一開始老師就交我們如何安裝驅動程式
接著直接摸索LeapMotion
而我也玩了一些範例遊戲
以下是我最為推薦的
像是這個幫機器人裝頭的
我玩了很多次,覺得超好玩!!!!!
當拿著頭靠近身體時會有一股電流將我吸住
每當裝完他們的頭,我會把他們再全拔掉
過程中不斷的摔打他們可愛的臉龐和嬌小的身軀
實在是令人大呼過癮^_^
而且畫面又溫馨可愛,手也需要協調才能完成動作
這實在是非常舒壓但又不會過於暴力血腥的和平益智遊戲
十分推薦初學者試試~~~~~
另外這個我看不太懂英文
不過我覺得這種遊戲應用在學習上非常有趣!!!!!
在這個充滿3C的時代
人人幾乎都有一支智慧型手機
對現在的小朋友而言,玩具或許已經不能滿足他們的慾望
而在學習上,傳統的紙本也許過於乏味
但如果用這種「寓教於樂」的方式
不但過程好玩有趣,又可以從中了解一些人體器官的知識等等
個人認為這設計非常好^_^
接著以下是安裝過程
以及最後程式執行結果
訂閱:
文章 (Atom)




























