PImage imgoil;
PImage imgbullet;
PImage imgiron;
PImage imgarumi;
float []thingX= new float[5], thingY= new float[5], thingType=new float[5];
void setup() {
size(400, 600);
imgoil=loadImage("oil.jpg");
imgbullet=loadImage("bullet.jpg");
imgiron=loadImage("iron.jpg");
imgarumi=loadImage("arumi.jpg");
for (int i=0;i<R;i++) {
newThing(i);
}
}
void draw() {
background(255);
for (int i=0;i<R;i++) {
if (thingType[i]==1)drawG(i);
else if (thingType[i]==2)drawB(i);
else if (thingType[i]==3)drawT(i);
else if (thingType[i]==4)drawA(i);
thingY[i]+=5;
if (thingY[i]>600)newThing(i);
}
}
void newThing(int i) {
thingY[i]=-random(200);
thingX[i]=random(400);
thingType[i]=int(random(4))+1;
}
void drawG(int i) {
image(imgoil, thingX[i], thingY[i], 40, 40);
}
void drawB(int i) {
image(imgbullet, thingX[i], thingY[i], 40, 40);
}
void drawT(int i) {
image(imgiron, thingX[i], thingY[i], 40, 40);
}
void drawA(int i) {
image(imgarumi, thingX[i], thingY[i], 40, 40);
}
沒有留言:
張貼留言