2018年10月4日 星期四

Week04_黃惠嘉

🔺程式


void setup(){
  size(800,600);
}
void draw(){
  text("Start!",100,100);文字Start
}

void setup(){
  size(800,600);
}
void draw(){
  rect(0,0,200,200);⇒正方形
  text("Start!",100,100);
}


void setup(){

  size(800,600);
}
void draw(){
  fill(255,0,0); rect(100,100,100,100);⇒fill(255,0,0)顏色紅
  fill(0,0,0); text("Start!",100,100);⇒fill(0,0,0)顏色黑
}



void setup(){

  size(800,600);
}
void draw(){
  fill(255,0,0); rect(100,100,100,100);
  textSize(80);⇒文字大小
  fill(0,0,0); text("Start!",100,100);
}


void setup(){

  size(800,600);
}
void draw(){
  background(255);⇒背景,把殘影用白
  fill(255,0,0); rect(mouseX,mouseY,100,100);
mouseX,mouseY跟著滑鼠動
  textSize(80);
  fill(0,0,0); text("Start!",mouseX,mouseY);
mouseX,mouseY跟著滑鼠動
}



void setup(){

  size(800,600);
}
void draw(){
  background(255);
  fill(255,0,0); rect(100,100,100,100);
  
}
float bulletX=100,bulletY=100;
void keyPressed(){⇒按鍵盤
  ellipse(bulletX,bulletY,50,50);
ellipse(a,b,c,d) 
afloat: x-coordinate of the ellipse
bfloat: y-coordinate of the ellipse
cfloat: width of the ellipse by default
dfloat: height of the ellipse by default



void setup(){

  size(800,600);
}
void draw(){
  background(255);
  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;boolean true or false
void keyPressed(){
   bulletFlying=true;



void setup(){

  size(800,600);
}
void draw(){
  background(255);
  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;
   bulletX=100;



void setup(){

  size(800,600);
}
void draw(){
  background(255);
  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++;



void setup(){

  size(800,600);
}
void draw(){
  background(255);
  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++;
   println(bulletN); println 印



PImage imgBullet; 用於存儲圖像的數據類型。

void setup(){
  size(800,600);
  imgBullet=loadImage("bullet.png");
}

void draw(){

  image(imgBullet,mouseX,mouseY);
}


PImage imgBullet;

PImage imgBG; 
void setup(){
  size(800,600);
  imgBG = loadImage("BG.jpg");
  imgBullet=loadImage("bullet.png");
  imageMode(CENTER);
}

void draw(){

  image(imgBG,width/2,height/2,width,height);
  image(imgBullet,mouseX,mouseY,100,100);
  for(int i=0;i<bulletN;i++){
    if(bulletFlying[i]){
      image(imgBullet,bulletX[i],bulletY[i],100,100);
    }
  }
}
float []bulletX = new float[100];
float []bulletY = new float[100];
boolean [] bulletFlying =new boolean[100];
int bulletN=0;
void mousePressed(){
  bulletFlying[bulletN]=true;
  bulletX[bulletN]=mouseX;
  bulletY[bulletN]=mouseY;
  bulletN++;
}



PImage imgBullet;

PImage imgBG; 
void setup(){
  size(800,600);
  imgBG = loadImage("BG.jpg");
  imgBullet=loadImage("bullet.png");
  imageMode(CENTER);
}
 
默認模式是imageMode(CORNER),它將image()的第二個和第三個參數解釋為圖像的左上角。 如果指定了兩個附加參數,則它們用於設置圖像的寬度和高度。

imageMode(CORNERS)將image()的第二個和第三個參數解釋為一個角的位置,將第四個和第五個參數解釋為對角。

imageMode(CENTER)將image()的第二個和第三個參數解釋為圖像的中心點。 如果指定了兩個附加參數,則它們用於設置圖像的寬度和高度。

void draw(){
  image(imgBG,width/2,height/2,width,height);
  image(imgBullet,mouseX,mouseY,100,100);
  for(int i=0;i<bulletN;i++){
    if(bulletFlying[i]){
      image(imgBullet,bulletX[i],bulletY[i],100,100);
      bulletX[i] += 3; 讓bulletX移動
    }
  }
}
float []bulletX = new float[100];
float []bulletY = new float[100];
boolean [] bulletFlying =new boolean[100];
int bulletN=0;
void mousePressed(){
  bulletFlying[bulletN]=true;
  bulletX[bulletN]=mouseX;
  bulletY[bulletN]=mouseY;
  bulletN++;
}

沒有留言:

張貼留言