顯示具有 01161124_鄭秝安 標籤的文章。 顯示所有文章
顯示具有 01161124_鄭秝安 標籤的文章。 顯示所有文章

2015年3月30日 星期一

Week06課堂作業

期中作品  貓狗大戰


step1:匯入背景


程式碼↓
PImage imgBG;
void setup(){
  size(800, 600);
  imgBG = loadImage("cd1.jpg");
  imgBG.resize(800, 600);
  imageMode(CENTER);
}
void draw(){
  background(imgBG);
}

step2:血量


程式碼↓
PImage imgBG;
float blood1 = 100, blood2 = 100;
void setup(){
  size(800, 600);
  imgBG = loadImage("cd1.jpg");
  imgBG.resize(800, 600);
  imageMode(CENTER);
}
void draw(){
  background(imgBG);
  fill(255,0,0);
  rect(350,35,blood1*2.7,15);
  rect(450,35,blood2*2.7,15);
  blood1 = -100+frameCount/10;
  blood2 = 100-frameCount/10;
}

2015年3月23日 星期一

第五周課堂作業

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

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(){
  nowY+=cos(nowA); nowX+=sin(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,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);
    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(800,600,P3D);
  leap = new LeapMotion(this);
}
void draw(){
  background(255);
  for(Hand hand : leap.getHands()){
    //println("yaw:"+hand.getYaw());
    println("pitch:"+hand.getPitch());
    //println("roll:"+hand.getroll());
    pushMatrix();
    translate(hand.getPosition().x,hand.getPosition().y);
    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();
}


import de.voidplus.leapmotion.*;
LeapMotion leap;

void setup(){
  size(800,600,P3D);
  leap = new LeapMotion(this);
}
void draw(){
  background(255);
  println(leap.getHands().size());
  fill(255,0,0);
  textSize(40);
  for(Hand hand : leap.getHands()){
    if(hand.isRight()){
      text("right:"+hand.getOutstrechtedFingers().size(),400,300);
    }else
    text("left:"+hand.getOutstrechtedFingers().size(),200,300);
  }
}