2019年10月31日 星期四

week08

---class 1---
接金幣,隨機數應用
---class 2----
函式--->讓程式可讀性增加
---------------期中作品進度///老師的教學 見FB的躲避球
int x=0;
int y=0;
int atkx,atky,all,time=0;
PVector A[]=new PVector[9];
PVector B[]=new PVector[9];
void setup()
{
  wallpaper();
  time=millis();
  size(1100,1100);
}
void draw()
{
   time++;
   if((time/60)%4==0)
   {
     wallpaper();
     attack();
   }
}
void attack()
{
  if((time/60)<30)
  {
    all=int(random(4,7));
    atkx=int(random(1,6));
    atky=(all-atkx)+1;
  }
  else
  {
    all=int(random(6,9));
    atkx=int(random(1,8));
    atky=(all-atkx)+1;
  }
  for(int i=0;i<=atkx;i++)
  {
    A[i]=new PVector((int(random(1,10)))*100+50,50);
    fill(0,255,0);
    rect(A[i].x,A[i].y,10,10);
    rect(A[i].x,A[i].y+1000,10,10);
    fill(255,0,0);
  }
   for(int j=0;j<=atky;j++)
  {
    B[j]=new PVector(50,(int(random(1,10))*100+50));
    fill(0,255,0);
    rect(B[j].x,B[j].y,10,10);
    rect(B[j].x+1000,B[j].y,10,10);
  }
}
void wallpaper()
{
  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寫法...