211213 week12
💛🔔
期末作業的開場小號
上週進度(續)
將球控制在滑鼠的位置內(現在球速過快)
👉程式碼
void setup(){
size(600,500,P3D);///場景為3D
camera(0,-70,120,0,0,0,0,1,0);
}
void draw(){
lights();//打光
background(112,146,190);
fill(34,177,76);//綠色
box(100,5,120);//綠色球桌
fill(255,0,0);//紅色
box(100,30,5);//紅色網子
fill(#502C0F);//桌腳的顏色
box(10,100,10);//咖色桌腳
fill(255,255,0);//球的顏色
pushMatrix();
//translate(-300,-250,70);
//5.8為控制速度(減速) ///5.0為控制速度(減速)
translate((mouseX-width/2)/5.8,(mouseY-height*0.9)/5.0,70);
//中心點-頁面寬度=滑鼠寬度中心(/2為微調) //中心點-頁面高度=滑鼠高度中心(*0.9為微調)
noStroke();sphere(5);//球的半徑
popMatrix();
}
把四個桌腳調整到正確的位置,以及適當的大小
👉程式碼
void setup(){
size(600,500,P3D);///場景為3D
camera(0,-70,120,0,0,0,0,1,0);
}
void draw(){
lights();//打光
background(112,146,190);
fill(34,177,76);//綠色
box(100,5,120);//綠色球桌
pushMatrix();
translate(0,-10,0);
fill(255,0,0);//紅色
box(98,20,5);//紅色網子
popMatrix();
pushMatrix();
translate(-40,35,50);
fill(#502C0F);//桌腳的顏色
box(10,70,10);//咖色桌腳
popMatrix();
pushMatrix();
translate(40,35,50);
fill(#502C0F);//桌腳的顏色
box(10,70,10);//咖色桌腳
popMatrix();
pushMatrix();
translate(-40,35,-50);
fill(#502C0F);//桌腳的顏色
box(10,70,10);//咖色桌腳
popMatrix();
pushMatrix();
translate(40,35,-50);
fill(#502C0F);//桌腳的顏色
box(10,70,10);//咖色桌腳
popMatrix();
fill(255,255,0);//球的顏色
pushMatrix();
//translate(-300,-250,70);
//6.5為控制速度(減速) ///5.0為控制速度(減速)
translate((mouseX-width/2)/6.5,(mouseY-height*0.92)/5.0,70);
//中心點-頁面寬度=滑鼠寬度中心(/2為微調) //中心點-頁面高度=滑鼠高度中心 (*0.92為微調)
noStroke();sphere(5);//球的半徑
popMatrix();
}
沒有留言:
張貼留言