做一個可移動的橫向卷軸圖
PImage img;
PImage img2;
void setup(){
size(800,500);
img = loadImage("image.png");
img2 = loadImage("logo.jpg");
}
int x=0;
void draw(){
if(mouseX>700)x--;
image(img , x , 0);
image(img2 ,mouseX-220/2, mouseY-337/2);
}
做一個會彈跳的球
float x=250, y=200;
float vx=1.3, vy=14;
void setup(){
size(500,400);
}
void draw(){
background(255);
ellipse(x,y,10,10);
x+=vx;
y+=vy;
vy+=0.98;
if(x>500 || x<0)vx = -vx*0.85;
if(y>400 || x<0)vy = -vy*0.85;
}


沒有留言:
張貼留言