2019年10月24日 星期四

05160151_week07

-第一堂課-
PVector user;
PVector userV;
void setup()
{
   size(400,400);
   user=new PVector(200,200); ///user的座標(向量)在200,200
   userV=new PVector(1,1);
}
void draw()
{
   background(255);背景白色
   ellipse(user.x,user.y,100,100); 畫圓 半徑100
   user.add(userV); user座標加上userV向量
   if(user.x>400-50)userV.x=-1;  撞到邊界後的反應(400-50是因為座標在圓心)
   if(user.y>400-50)userV.y=-1;
   if(user.x<50)userV.x=+1;
   if(user.y<50)userV.y=+1;
}
---電流急急棒---
PImage imgMap;
void setup()
{
   size(400,400);
   imgMap=loadImage("map.png");
   imgMap.loadPixels();//把圖片的值放到pixels[]裡
}
void draw()
{
  background(imgMap);
  if(imgMap.pixels[mouseX+mouseY*400]==color(255,0,0)
  {
     background(255,0,0);
     ///pixels[mouseX+mouseY*400] 表示滑鼠作標對應第幾個pixels
  }
  fill(imgMap.pixels[mouseX+mouseY*400]);
  rect(250,250,100,100);
}
--------------------期中作品進度------------
int x=0;
int y=0;
void setup()
{
   size(1100,1100);
}
void draw()
{
 for(int q=0;q<12;q++)
 {
   line(x,0,x,height);
   x+=100;
 }
 for(int w=0;w<12;w++)
  {
    line(0,y,width,y);
    y+=100;
  }
  for(int e=0;e<12;e++)
  {
   rect(0,e*100,100,100);
   fill(255,0,0);
  }
  for(int r=0;r<12;r++)
  {
   rect(1000,r*100,100,100);
   fill(255,0,0);
  }
  for(int t=0;t<12;t++)
  {
   rect(t*100,0,100,100);
   fill(255,0,0);
  }
  for(int y=0;y<12;y++)
  {
   rect(y*100,1000,100,100);
   fill(255,0,0);
  }
}

沒有留言:

張貼留言

alanhc 互動技術-week17 [final]

回顧這學期的作品:  期中作業:LANDING:PLANET 賣點&特點: 炫麗的特效 物理(星球重力及降落)及粒子系統(噴射) 世界地圖可根據視角縮放 困難點: 重寫3次最終改寫成物件導向的CLASS寫法...