Week07-08:10提早到(´∀`)
------------------------------------------------------------------------------------------------------------------------------------------------
◎提早到多學習-弄出手繪透明圖~
先到小畫家作畫,儲存圖片後到Powerpoint去背景
◎讀入有去背景和沒去背景的圖
PImage img, img_png;
void setup(){ size(500,500); img=loadImage("star.png"); img_png=loadImage("star_1.png"); } void draw(){ background(0); image(img,100,100); image(img_png,0,0); }
●Step01-用簡單的圓形做出彈來彈去的球(碰到邊界不會不見)
《程式碼》
PVector user; PVector userV; void setup(){ size(400,400); user=new PVector(200,200); userV = new PVector(1,1); } void draw(){ background(255); ellipse(user.x,user.y,100,100); user.add(userV); if(user.x>400-50) userV.x=-1; if(user.y>400-50) userV.y=-1; if(user.x<50) userV.x=+1; if(user.y<50) userV.y=+1; }
.
●Step02-電流極極棒(碰到邊邊框框會變顏色)
《程式碼》
PImage imgMap; void setup(){ size(400,400); imgMap=loadImage("map.png"); imgMap.loadPixels(); } void draw(){ background(imgMap); if(imgMap.pixels[mouseX+mouseY*400]==color(255,0.0)){ background(255,0,0); } fill(imgMap.pixels[mouseX+mouseY*400]); rect(250,250,100,100); }●Step03-月光閃亮亮
《程式碼》
int[] value = new int[100];//準備[陣列]的格子,100個
PVector[]bullet= new PVector[100];//準備[陣列]的格子,100個
PVector[]bulletV= new PVector[100];//準備[陣列]的格子,100個
void setup(){
size(500,500);
for(int i=0;i<100;i++){
bullet[i] = new PVector( random(500),random(500) );
bulletV[i] = new PVector( random(4)-2,random(4)-2 );
}
}
void draw(){
background(0);
for(int i=0;i<100;i++){
fill(255);
bullet[i].add(bulletV[i]);
ellipse(bullet[i].x,bullet[i].y,5,5);
if(bullet[i].x<0){ bullet[i].x=0; bulletV[i].x = random(2);}
if(bullet[i].x>500){ bullet[i].x=500; bulletV[i].x = -random(2);}
if(bullet[i].y<0){ bullet[i].y=0; bulletV[i].x= random(2);}
if(bullet[i].y>500){ bullet[i].y=500; bulletV[i].y = -random(2);}
}
}






沒有留言:
張貼留言