2020年3月27日 星期五

Week04-陣列與指標,發射子彈

這是今天上課的內容:
PImage imgBG;
int []x={0,0,0,0,0};
int []y={0,0,0,0,0};
int n=0;
void setup(){
  size(1152,1280);
  imgBG=loadImage("123.png");
}
void draw(){
   background(imgBG);
   for(int i=0; i<5; i++){
     circle(x[i], y[i], 40);
   }
}
void mousePressed(){
  //if(n>=5) return;
  x[n]=mouseX;
  y[n]=mouseY;
  n = (n+1)%5;
}

沒有留言:

張貼留言