week04
匯入照片
顯示圖片
PImage img;
size(730,730);
img=loadImage("image.png");
image(img,0,0);
PImage img;
PImage img2;
size(730,730);
img=loadImage("image.png");
img2=loadImage("images.png");
image(img,0,0);
image(img2,500,400,224,224);
移動第二張照片
PImage img;
PImage img2;
void setup(){
size(730,730);
img=loadImage("image.png");
img2=loadImage("images.png");
}
void draw(){
image(img,0,0);
image(img2,mouseX-224/2,mouseY-224/2,224,224);
}
背景圖移動
PImage img;
PImage img2;
void setup(){
size(600,518);
img=loadImage("xxx.png");
img2=loadImage("zzz.png");
}
int x=0;
void draw(){
if(mouseX>300) x--;
image(img,x,0);
image(img2,mouseX-224/2,mouseY-224/2,224,224);
}
float x=250, y=200;
float vx=0, vy=0;
void setup(){
size(500,400);
}
void draw(){
if(mousePressed) line(mouseX,mouseY,x,y);
ellipse(x,y,10,10);
ellipse(mouseX,mouseY,10,10);
x+=vx; y+=vy;
if(x>500 || x<0) vx = -vx;
if(y>400 || y<0) vy = -vy;
}
void mouseReleased(){
vx=x-mouseX; vy=y-mouseY;
}
float x=250, y=200;
float vx=1.3, vy=14;
void setup(){
size(500,400);
}
void draw(){
ellipse(x,y,10,10);
x+=vx; y+=vy;
vy+=0.98;
if(x>500 || x<0) vx = -vx*0.85;
if(y>400 || y<0) vy = -vy*0.85;
}









沒有留言:
張貼留言