2012年11月12日 星期一

摩天輪範例


int[] poseX = new int[10];
int[] poseY = new int[10];

float angle;

void setup()
{
  size(600, 600);
  background(0, 120, 0);
  angle = TWO_PI/10;
}

void draw()
{
  background(100, 100, 100);
  for (int i = 0 ; i < 10 ; i++)
  {
    poseX[i] = (int)(width/2 + 90*cos((i+1)*angle));
    poseY[i] = (int)(height/2 + 90*sin((i+1)*angle));
    fill(50, 50, 50);
    rect(poseX[i], poseY[i], 20, 28);
  }
}

沒有留言:

張貼留言