//week12-1-gumdam-head-body-push-uparm-upuparm-hand
PShape body,head; PShape uparm1,upuparm1,hand1; void setup(){ size(400,400,P3D); body = loadShape("body.obj"); head = loadShape("head.obj"); uparm1 = loadShape("uparm1.obj"); upuparm1 = loadShape("upuparm1.obj"); hand1 = loadShape("hand1.obj"); } void draw(){ background(204); translate(200,300); sphere(10);//原點的球 scale(10,-10,10);//y要上下再反過來 shape(body,0,0); pushMatrix(); translate(0,22.5); rotateY(radians(mouseX-200)); rotateX(radians(mouseY-60)); translate(0,-22.5); shape(head,0,0); popMatrix(); pushMatrix(); shape(upuparm1,0,0);//上上手臂 pushMatrix(); translate(-4.1,19.9); rotateZ(radians(mouseX)); translate(4.1,-19.9); //translate(mouseX/10.0,-mouseY/10.0);//一邊移動,一邊找到數值 //println(mouseX/10.0,-mouseY/10.0);//印出適合的數值,(小黑) shape(uparm1,0,0);//上手臂 pushMatrix(); translate(-4.5,16.9); rotateX(radians(mouseY)); translate(4.5,-16.9); //translate(mouseX/10.0,-mouseY/10.0);//一邊移動,一邊找到數值 //println(mouseX/10.0,-mouseY/10.0);//印出適合的數值,(小黑) shape(hand1,0,0);//上手臂 popMatrix(); popMatrix(); popMatrix(); }//week12-2-gumdam-head-body-uparm-upuparm-hand-angle PShape body,head; PShape uparm1,upuparm1,hand1; void setup(){ size(400,400,P3D); body = loadShape("body.obj"); head = loadShape("head.obj"); uparm1 = loadShape("uparm1.obj"); upuparm1 = loadShape("upuparm1.obj"); hand1 = loadShape("hand1.obj"); } float [] angleX = new float[10]; float [] angleY = new float[10]; int ID = 0; void mouseDragged(){ angleX[ID] += radians(mouseX - pmouseX); angleY[ID] += radians(mouseY - pmouseY); } void draw(){ background(204); translate(200,300); sphere(10);//原點的球 scale(10,-10,10);//y要上下再反過來 shape(body,0,0); pushMatrix(); translate(0,22.5); rotateY(angleX[0]); rotateX(angleY[0]); translate(0,-22.5); shape(head,0,0); popMatrix(); pushMatrix(); shape(upuparm1,0,0);//上上手臂 pushMatrix(); translate(-4.1,19.9); // rotateZ(radians(mouseX)); rotateZ(angleY[2]); rotateY(angleX[2]); translate(4.1,-19.9); //translate(mouseX/10.0,-mouseY/10.0);//一邊移動,一邊找到數值 //println(mouseX/10.0,-mouseY/10.0);//印出適合的數值,(小黑) shape(uparm1,0,0);//上手臂 pushMatrix(); translate(-4.5,16.9); //rotateX(radians(mouseY)); rotateX(angleY[3]); rotateY(angleX[3]); translate(4.5,-16.9); //translate(mouseX/10.0,-mouseY/10.0);//一邊移動,一邊找到數值 //println(mouseX/10.0,-mouseY/10.0);//印出適合的數值,(小黑) shape(hand1,0,0);//上手臂 popMatrix(); popMatrix(); popMatrix(); }//week12_3_gumdam_head_body_left_keyPressed-ID PShape body,head; PShape uparm1,upuparm1,hand1; void setup(){ size(400,400,P3D); body = loadShape("body.obj"); head = loadShape("head.obj"); uparm1 = loadShape("uparm1.obj"); upuparm1 = loadShape("upuparm1.obj"); hand1 = loadShape("hand1.obj"); } float [] angleX = new float[10]; float [] angleY = new float[10]; int ID = 0; void mouseDragged(){ angleX[ID] += radians(mouseX - pmouseX); angleY[ID] += radians(mouseY - pmouseY); } void keyPressed(){ if(key == '1') ID = 1; if(key == '2') ID = 2; if(key == '3') ID = 3; if(key == '4') ID = 4; if(key == '5') ID = 5; if(key == '6') ID = 6; if(key == '7') ID = 7; if(key == '8') ID = 8; if(key == '9') ID = 9; if(key == '0') ID = 0; } void draw(){ background(204); translate(200,300); sphere(10);//原點的球 scale(10,-10,10);//y要上下再反過來 shape(body,0,0); pushMatrix(); translate(0,22.5); rotateY(angleX[0]); rotateX(angleY[0]); translate(0,-22.5); shape(head,0,0); popMatrix(); pushMatrix(); shape(upuparm1,0,0);//上上手臂 pushMatrix(); translate(-4.1,19.9); rotateZ(angleY[2]); rotateY(angleX[2]); translate(4.1,-19.9); shape(uparm1,0,0);//上手臂 pushMatrix(); translate(-4.5,16.9); rotateX(angleY[3]); rotateY(angleX[3]); translate(4.5,-16.9); shape(hand1,0,0);//上手臂 popMatrix(); popMatrix(); popMatrix(); }//week12_4_gumdam_head_body_push_trt_pop_again PShape body,head; PShape uparm1,upuparm1,hand1; void setup(){ size(400,400,P3D); body = loadShape("body.obj"); head = loadShape("head.obj"); uparm1 = loadShape("uparm1.obj"); upuparm1 = loadShape("upuparm1.obj"); hand1 = loadShape("hand1.obj"); } float [] angleX = new float[10]; float [] angleY = new float[10]; int ID = 0; void mouseDragged(){ angleX[ID] += radians(mouseX - pmouseX); angleY[ID] += radians(mouseY - pmouseY); } void keyPressed(){ if(key == '1') ID = 1; if(key == '2') ID = 2; if(key == '3') ID = 3; if(key == '4') ID = 4; if(key == '5') ID = 5; if(key == '6') ID = 6; if(key == '7') ID = 7; if(key == '8') ID = 8; if(key == '9') ID = 9; if(key == '0') ID = 0; } void draw(){ background(204); translate(200,300); sphere(10);//原點的球 scale(10,-10,10);//y要上下再反過來 shape(body,0,0); pushMatrix(); translate(0,22.5); rotateY(angleX[0]); rotateX(angleY[0]); translate(0,-22.5); shape(head,0,0); popMatrix(); pushMatrix(); translate(-2.9,20.8); rotateY(angleX[1]); rotateX(angleY[1]); translate(2.9,-20.8); //translate(mouseX/10.0, -mouseY/10.0)//要找旋轉中心,不是直接放在黑點上就好 //println(mouseX/10.0, -mouseY/10.0) shape(upuparm1,0,0);//上上手臂 pushMatrix(); translate(-4.1,19.9); rotateZ(angleY[2]); rotateY(angleX[2]); translate(4.1,-19.9); shape(uparm1,0,0);//上手臂 pushMatrix(); translate(-4.5,16.9); rotateX(angleY[3]); rotateY(angleX[3]); translate(4.5,-16.9); shape(hand1,0,0);//上手臂 popMatrix(); popMatrix(); popMatrix(); }//week12_5_gumdam_left_copy_right PShape body,head; PShape uparm1,upuparm1,hand1; PShape uparm2,upuparm2,hand2; void setup(){ size(400,400,P3D); body = loadShape("body.obj"); head = loadShape("head.obj"); uparm1 = loadShape("uparm1.obj"); upuparm1 = loadShape("upuparm1.obj"); hand1 = loadShape("hand1.obj"); uparm2 = loadShape("uparm2.obj"); upuparm2 = loadShape("upuparm2.obj"); hand2 = loadShape("hand2.obj"); } float [] angleX = new float[10]; float [] angleY = new float[10]; int ID = 0; void mouseDragged(){ angleX[ID] += radians(mouseX - pmouseX); angleY[ID] += radians(mouseY - pmouseY); } void keyPressed(){ if(key == '1') ID = 1; if(key == '2') ID = 2; if(key == '3') ID = 3; if(key == '4') ID = 4; if(key == '5') ID = 5; if(key == '6') ID = 6; if(key == '7') ID = 7; if(key == '8') ID = 8; if(key == '9') ID = 9; if(key == '0') ID = 0; } void draw(){ background(204); translate(200,300); sphere(10);//原點的球 scale(10,-10,10);//y要上下再反過來 shape(body,0,0); pushMatrix(); translate(0,22.5); rotateY(angleX[0]); rotateX(angleY[0]); translate(0,-22.5); shape(head,0,0); popMatrix(); pushMatrix(); translate(-2.9,20.8); rotateY(angleX[1]); rotateX(angleY[1]); translate(2.9,-20.8); //translate(mouseX/10.0, -mouseY/10.0)//要找旋轉中心,不是直接放在黑點上就好 //println(mouseX/10.0, -mouseY/10.0) shape(upuparm1,0,0);//上上手臂 pushMatrix(); translate(-4.1,19.9); rotateZ(angleY[2]); rotateY(angleX[2]); translate(4.1,-19.9); shape(uparm1,0,0);//上手臂 pushMatrix(); translate(-4.5,16.9); rotateX(angleY[3]); rotateY(angleX[3]); translate(4.5,-16.9); shape(hand1,0,0);//上手臂 popMatrix(); popMatrix(); popMatrix(); pushMatrix(); translate(2.9,20.8); rotateY(angleX[4]); rotateX(angleY[4]); translate(-2.9,-20.8); //translate(mouseX/10.0, -mouseY/10.0)//要找旋轉中心,不是直接放在黑點上就好 //println(mouseX/10.0, -mouseY/10.0) shape(upuparm2,0,0);//上上手臂 pushMatrix(); translate(4.1,19.9); rotateZ(angleY[5]); rotateY(angleX[5]); translate(-4.1,-19.9); shape(uparm2,0,0);//上手臂 pushMatrix(); translate(4.5,16.9); rotateX(angleY[6]); rotateY(angleX[6]); translate(-4.5,-16.9); shape(hand2,0,0);//上手臂 popMatrix(); popMatrix(); popMatrix(); }-------------------------------------------------------------
//week12-6-sound import processing.sound.*; SoundFile mySound; void setup(){ size(400,400); mySound = new SoundFile(this, "music.mp3"); mySound. play(); } void draw(){//必須要有,才能持續更新 }//week12-7-sound1-sound2-sound3 import processing.sound.*; SoundFile sndingame,sndintro,sndmonkey,sndsword; void setup(){ size(400,400); sndingame = new SoundFile(this, "In Game Music.mp3"); sndintro = new SoundFile(this, "Intro Song_Final.mp3"); sndmonkey = new SoundFile(this, "Monkey 1.mp3"); sndsword = new SoundFile(this, "sword slash.mp3"); sndintro. play(); } boolean playingintro = true; void keyPressed(){ if(playingintro){ sndintro.stop(); sndingame.play(); playingintro = false; } else{ sndingame.stop(); sndintro. play(); playingintro = true; } } void mousePressed(){ if(mouseButton == LEFT) sndsword.play(); if(mouseButton == RIGHT) sndmonkey.play(); } void draw(){}








沒有留言:
張貼留言