2018年10月4日 星期四

Week04

1.























2.






















void setup()
{
  size(800,600);
  //img = loadImage("...");
}
void draw()
{
  //image(img, 0, 0);
  fill(255,0,0); rect(0,0,200,200);
  fill(0,0,0); text("Start!", 100, 100);
}

3. 將字體變大


 void setup()
{
  size(800,600);
  //img = loadImage("...");
}
void draw()
{
  //image(img, 0, 0);
  fill(255,0,0); rect(100,100,100,100);
  textSize(80);
  fill(0,0,0); text("Start!", 100, 100);


4. 字體移動



  void setup()
{
  size(800,600);
  //img = loadImage("...");
}
void draw()
{
  background(255);
  //image(img, 0, 0);
  fill(255,0,0); rect(mouseX,mouseY,100,100);
  textSize(80);
  fill(0,0,0); text("Start!", mouseX,mouseY);
}

5. 鍵盤發射子彈(但是只能一顆)

void setup()
{
  size(800,600);
  //img = loadImage("...");
}
void draw()
{
  background(255);
  //image(img, 0, 0);
  fill(255,0,0); rect(100,100,100,100);
  if(bulletFlying)
  {
    ellipse(bulletX,bulletY, 50,50);
    bulletX+=3;
  } 
}
float bulletX=100, bulletY=100;
boolean bulletFlying=false;
void keyPressed()
{
  bulletFlying=true;
}

6. 發射多顆子彈

void draw()
{
  background(255);
  //image(img, 0, 0);
  fill(255,0,0); rect(100,100,100,100);
  for (int i=0;i<bulletN;i++)
  {
    if(bulletFlying[i])
    {
        ellipse(bulletX[i],bulletY[i], 50,50);
        bulletX[i]+=3;
    }
  } 
}
float []bulletX= new float[100];
float []bulletY= new float[100];
int bulletN=0;
boolean []bulletFlying= new boolean[100];
void keyPressed()
{
  bulletFlying[ bulletN ]=true;
  bulletX[ bulletN ]=100;  bulletY[ bulletN ]=100;
  bulletN++;
}

7.



8.

沒有留言:

張貼留言