PImage imgBG;
int []x={0,0,0,0,0};
int []y={0,0,0,0,0};
void setup(){
size(580,326);
imgBG=loadImage("1.jpg");
}
void draw(){
background(imgBG);
circle(x[0], y[0], 40);
}
void mousePressed(){
x[0] = mouseX;
y[0] = mouseY;
}

02.設個陣列,因為子彈不會只有一顆。
PImage imgBG;
int []x={0,0,0,0,0};
int []y={0,0,0,0,0};
int n=0; ///子彈數目,現在用了0顆子彈。
void setup(){
size(580,326);
imgBG=loadImage("1.jpg");
}
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++;

int []a={1,1,1,0};
size(400,100);
for(int i=0; i<4; i++){
if(a[i]==1) fill(255,0,0);
else fill(128);
rect (i*100,0, 100,100);
}
}

int [][]a={
{1,0,0,0,1},
{0,1,0,1,0},
{1,1,1,1,0},
{0,0,1,0,0},
{1,0,0,0,0}};
size(500,500);
for(int i=0; i<5; i++){
for(int j=0; j<5; j++){
if( a[i][j] == 1 ) fill(255,0,0);
else fill(128);
rect (j*100,i*100, 100,100);
}
}

PImage imgBG;
int []x={0,0,0,0,0};
int []y={0,0,0,0,0};
int []r={5,5,5,5,5};
int n=0;
void setup(){
size(580,326);
imgBG=loadImage("1.jpg");
}
void draw(){
background(imgBG);
for(int i=0;i<5; i++) {
circle(x[i], y[i], r[i]);
}
if(mousePressed) r[now]++;
}
int now=0;
void mousePressed(){
///if(n>=5)return;
x[n] = mouseX;
y[n] = mouseY;
now=n;
n = (n+1)%5;
}

沒有留言:
張貼留言