///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
I 've learned how to control the loaded image and I got the concept of controlling Icon on the background.
PImage img;
int i;
int x;
int t;
int s;
int y;
int y1;
void setup()
{
size(1000, 300);
i=0;
s=100;
t=255;
y=20;
y1=20;
img = loadImage("robot.jpg");
frameRate(20);
}
void draw()
{
background(255);
//horizental
if ( (keyPressed == true) && ( (key =='a') || (key == 'A') ))
i=i+20;
else if( (keyPressed == true) && ( (key =='b') || (key == 'B') ))
i=i-20;
else if ( (keyPressed == true) && ( (key =='c') || (key == 'C') ))
i+=y;
if(i>900)
{
i=900;
y=-y;
}
else if(i<0)
{
i=0;
y=-y;
}
//virtical
if ( (keyPressed == true) && ( (key =='d') || (key == 'D') ))
x=x+20;
else if( (keyPressed == true) && ( (key =='e') || (key == 'E') ))
x=x-20;
else if ( (keyPressed == true) && ( (key =='f') || (key == 'F') ))
x+=y1;
if(x>200)
{
x=200;
y1=-y1;
}
else if(x<0)
{
x=0;
y1=-y1;
}
//tint
if( (keyPressed == true) && ( (key =='h') || (key == 'H') ))
t=t-5;
if( (keyPressed == true) && ( (key =='i') || (key == 'I') ))
t=t+5;
if(t<0)t=0;
if(t>255) t=255;
tint(t);
image(img,i, x,s,s);
}

沒有留言:
張貼留言