今日目標 :
1.做出一雙眼睛,眼球能夠跟著滑鼠走
2.泡泡龍射擊
.想出期中作業
重要概念 :
1. stan →
一、先畫出兩個眼眶
二、畫出眼球
三、讓眼珠能夠跟著滑鼠走

程式碼:
void setup(){
size (800,800);
}
void draw(){
background(128); ///gray
strokeWeight(20);
ellipse(100,200 ,180,360);
ellipse(300,200 ,180,360);
//ellipse(100,200 ,10,10);
//ellipse(300,200 ,10,10);
float angle1 = atan2((mouseY-200)/2 , mouseX-300);
float newX1= 300 + 100*cos(angle1)/2;
float newY1= 200 + 200*sin(angle1)/2;
ellipse(newX1 , newY1 ,10 ,10);
float angle2 = atan2((mouseY-200)/2 , mouseX-100);
float newX2= 100 + 100*cos(angle2)/2;
float newY2= 200 + 200*sin(angle2)/2;
ellipse (newX2 ,newY2 ,10 ,10);
}
一、做出泡泡龍的射擊
程式碼:
void setup(){
size (400,800);
}
float ballX=200 ,ballY=600;
float ballVX=0 ,ballVY=0;
float angle=0;
void draw(){
background(0,128,0);
fill(#FCC557); ellipse(200,600,100,100);
line(mouseX, mouseY,200,600);
fill(#D2FF21); ellipse(ballX,ballY,30,30);
angle = atan2(mouseY-600, mouseX-200);
ballX+=ballVX;
ballY+=ballVY;
}
void mouseMoved(){
ballX=200+50*cos(angle);
ballY=600+50*sin(angle);
}
void mousePressed(){
ballVX=cos(angle);
ballVY=sin(angle);
}
二、讓射擊出去的球,可以回收
沒有留言:
張貼留言