2019年10月31日 星期四

Week08 葉政翰

1. 介紹隨機位置



程式碼:

PVector[] cup = new PVector[3];
PVector[] cupV= new PVector[3];
int guess;
void setup()
{
  size(400, 300);
  for(int i =0;i<3;i++)
  {
    cup[i] =new PVector(100+i*100, 100);
    cupV[i] =new PVector(random(4), random(3));
  }
  guess = int(random(3));
  println(guess);
}

void draw()
{
  background(255);
  for(int i=0;i<3;i++)
  {
    cup[i].add(cupV[i]);
    if(cup[i].x<0 || cup[i].x>400) cupV[i].x*=-1;
    if(cup[i].y<0 || cup[i].y>300) cupV[i].y*=-1;
    fill(255);
    ellipse(cup[i].x, cup[i].y, 90, 60);
  }
}

沒有留言:

張貼留言

alanhc 互動技術-week17 [final]

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