
PImage img0,img1,img2;
void setup(){
size(400,400);
img0 = loadImage ("1.png");///導入圖片
}
void draw(){
background(128);
image(img0, mouseX,mouseY);///圖片跟著滑鼠
}

PImage img0,img1,img2;
void setup(){
size(400,400);
img0 = loadImage ("02.png");
img1 = loadImage ("03.png");
img2 = loadImage ("04.png");
}
int userX=250,userY=250;
void draw(){
background(128);
if(keyPressed && keyCode==LEFT){///鍵盤點左,人物往左跑

image(img0, userX,userY);
userX--;
}
else if(keyPressed && keyCode==RIGHT){///方向鍵點右,往右跑

image(img1, userX,userY);
userX++;
}else image(img2, userX,userY);
}

PImage img,img0,img1,img2;
void setup(){
size(768,1280);
img = loadImage ("5.png");///增設背景
img0 = loadImage ("02.png");
img1 = loadImage ("03.png");
img2 = loadImage ("04.png");
}
int userX=250,userY=250;
void draw(){
background(img);
if(keyPressed && keyCode==LEFT){
image(img1, userX,userY);
userX--;
}
else if(keyPressed && keyCode==RIGHT){
image(img2, userX,userY);
userX++;
}
else if(keyPressed && keyCode==UP){///上鍵往上
image(img0, userX,userY);
userY--;
}
else image(img0, userX,userY);
}
PImage img,img0,img1,img2;
void setup(){
size(768,1280);
img = loadImage ("5.png");
img0 = loadImage ("02.png");
img1 = loadImage ("03.png");
img2 = loadImage ("04.png");
}
int userX=250,userY=250;
int []bulletX={0,0,0,0,0};
int []bulletY={0,0,0,0,0};
int []bulletFlying={0,0,0,0,0};
int n=0;
void draw(){
background(img);
if(keyPressed && keyCode==LEFT){
image(img1, userX,userY);
userX--;
}
else if(keyPressed && keyCode==RIGHT){
image(img2, userX,userY);
userX++;
}
else if(keyPressed && keyCode==UP){
image(img0, userX,userY);
userY--;
}else image(img0, userX,userY);
for(int i=0;i<n;i++){
if(bulletFlying[i]==1)
ellipse(bulletX[i], bulletY[i], 5,10);
bulletY[i]-=2;
}
}
void mousePressed(){
bulletX[n]=userX;
bulletY[n]=userY;
bulletFlying[n]=1;
n++;
}
沒有留言:
張貼留言