2020年4月10日 星期五

week07


加入程式設計二teams 團隊

codeblocks指標

C tutor

processing

移動的箭頭
PImage img1,img2,img3;
PImage img;
float x=100,y=100,vx=0;
void setup()
{
  size(300,300);
  img1=loadImage("img1.png");
  img2=loadImage("img2.png");
  img3=loadImage("img3.png");
  img=img1;
}
void draw()
{
  background(255);
  image(img,x,y);
  x+=vx;
}
void keyPressed()
{
  if(keyCode==RIGHT)
  {
    img=img3;
    vx=1;
  }
  else if(keyCode==LEFT)
  {
    img=img2;
    vx=-1;
  }
}
void keyReleased()
{
  img=img1;
  vx=0;
}

彈跳多拉A夢
PImage img1,img2,img3;
PImage img;
float x=100,y=100,vx=0,vy=-10;
void setup()
{
  size(300,300);
  img1=loadImage("dora.png");
  img2=loadImage("img2.png");
  img3=loadImage("img3.png");
  img=img1;
}
void draw()
{
  background(255);
  image(img,x,y,100,100);
  x+=vx;
  y+=vy;
  vy+=0.98;
  if(y>=200)vy=-vy*0.9;
}
void keyPressed()
{
  if(keyCode==RIGHT)
  {
    img=img3;
    vx=1;
  }
  else if(keyCode==LEFT)
  {
    img=img2;
    vx=-1;
  }
}
void keyReleased()
{
  img=img1;
  vx=0;
}


一直彈跳多拉A夢
PImage img;
float x=100,y=100,vx=3,vy=-10;
void setup()
{
  size(400,400);
  img=loadImage("dora.png");
}
void draw()
{
  background(255);
  image(img,x,y);
  x+=vx;
  y+=vy;
  vy+=0.98;
  if(y>=200)vy=-vy*0.9;
  if(x>300)vx=-vx;
  if(x<0)vx=-vx;

}




沒有留言:

張貼留言