2021年12月6日 星期一

我出一百萬

 Week13----期末作品初步_____123木頭人👀👀


第一代:




程式碼👇:

///一二三木頭人, 3D

void setup(){

  size(600,300,P3D);//OpenGL

  noStroke();

}

void draw(){

  background(#FFD436);

  ghost();    

}

void ghost(){

  fill(237,137,63);

  rect(100,100,100,100);

  pushMatrix();

    lights(); ortho();

    translate(150,50);

    rotateY(radians(frameCount));

    

    fill(190,162,95);//head

    sphere(50);

    pushMatrix();

      translate(50,-10,50);

      fill(0); sphere(10);//

    popMatrix();

    pushMatrix();

      translate(-50,-10,50);

      fill(0); sphere(10);//

      popMatrix();  

  popMatrix();

}


第二代:


滑鼠左滑(-90背對)😏











滑鼠左滑(90看著參賽者)👿👿👿










程式碼👇:

///一二三木頭人, 3D

void setup(){

  size(600,300,P3D);//OpenGL

  noStroke();

}

void draw(){

  background(#FFD436);

  ghost(mouseX);//鬼要看的角度:-90背對沒看,90看到你 

}

void ghost(float angle){

  fill(237,137,63);

  rect(100,100,100,100);

  pushMatrix();

    lights(); ortho();

    translate(150,50);//把整個會轉的頭,移到身體上

    rotateY(radians(angle));

    

    fill(190,162,95);//head

    sphere(50);//大頭

    pushMatrix();

      translate(40,-10,50);

      fill(0); sphere(10);//黑色的右眼

    popMatrix();

    pushMatrix();

      translate(-40,-10,50);

      fill(0); sphere(10);//黑色的左眼

      popMatrix();  

  popMatrix();

}


第三代(會不定時轉動):





///背對你




///要準備抓你了!!!





///不准動!!動了你就GG了





程式碼👇:


///一二三木頭人, 3D

void setup(){

  size(600,300,P3D);//OpenGL

  noStroke();

  genRandomTime();

}

void genRandomTime(){

  time = millis()+random(3000,5000);

}

float time=0;

float angle=-90;

float speed=3;

void draw(){

  background(#FFD436);

  if(time < millis() ){//animation鬼要動了!!!

    //ghostMoving=true;

    angle+=speed;

    if(angle>=90){//鬼在看你

      angle=90;

      time = millis()+3000;//rest

      speed = -speed;

    }else if(angle<-90){

      angle=-90;

      genRandomTime();

      speed=3;

    }

  }

  ghost(angle);//鬼要看的角度:-90背對沒看,90看到你 

}

void ghost(float angle){

  fill(237,137,63);

  rect(100,100,100,100);

  pushMatrix();

    lights(); ortho();

    translate(150,50);//把整個會轉的頭,移到身體上

    rotateY(radians(angle));

    

    fill(190,162,95);//head

    sphere(50);//大頭

    pushMatrix();

      translate(40,-10,50);

      fill(0); sphere(10);//黑色的右眼👀

    popMatrix();

    pushMatrix();

      translate(-40,-10,50);

      fill(0); sphere(10);//黑色的左眼👀

      popMatrix();  

  popMatrix();

}



未來改良: 碰到鬼的距離要加長,鬼轉動的速度希望搭配音樂

沒有留言:

張貼留言