2020年6月19日 星期五

week17


void setup()
{
  size(300,300);
}
void draw()
{
  background(#002966);
  stroke(#b7efff);
  line(100,150,200,150);

  fill(#b7efff);
  ellipse(100,150,13,13);
  ellipse(200,150,13,13);
}
void setup()
{
  size(300,300);
}
float x=100, y=150;
void draw()
{
  background(#002966);
  stroke(#b7efff);
  line(x,y,200,150);

  fill(#b7efff);
  ellipse(x,y,13,13);
  ellipse(200,150,13,13);
}
void mouseDragged()
{
  x=mouseX; y=mouseY;
}
void setup()
{
  size(300,300);
}
float x=100, y=150;
void draw()
{
  background(#002966);
  stroke(#b7efff);
  line(x,y,200,150);

  fill(#b7efff);
  ellipse(x,y,13,13);
  ellipse(200,150,13,13);
  if( ! mousePressed )
  {
    float dx=x-200;
    float dy=y-150;
    float len=sqrt(dx*dx+dy*dy);
    x -= dx*(len-100)/len;
    y -= dy*(len-100)/len;
  }
}
void mouseDragged()
{
  x=mouseX; y=mouseY;
}
void setup()
{
  size(300,300);
}
float x=100, y=150;
void draw()
{
  background(#002966);
  stroke(#b7efff);
  line(x,y,200,150);

  fill(#b7efff);
  ellipse(x,y,13,13);
  ellipse(200,150,13,13);
  if( ! mousePressed )
  {
    float dx=x-200;
    float dy=y-150;
    float len=sqrt(dx*dx+dy*dy);
    x -= dx*(len-100)/len*0.1;//每次走/10
    y -= dy*(len-100)/len*0.1;//每次走/10
  }
}
void mouseDragged()
{
  x=mouseX; y=mouseY;
}
void setup()
{
  size(400,300);
}
float x=100, y=150;
void draw()
{
  background(#002966);
  ellipse(x,y,50,50);

  float dx=x-mouseX;
  float dy=y-mouseY;
  float len=sqrt(dx*dx+dy*dy);
  x -= dx*0.1;
  y -= dy*0.1;
}
void setup()
{
  size(400,300);
}
float x=100, y=150;
void draw()
{
  background(#002966);
  ellipse(x,y,50,50);

  float dx=x-mouseX;
  float dy=y-mouseY;
  float len=sqrt(dx*dx+dy*dy);
  x -= dx*(len-100)/len*0.1;//保持100的距離
  y -= dy*(len-100)/len*0.1;//保持100的距離
}
void setup()
{
  size(300,300);
}
float x=100, y=150,vx,vy;
void draw()
{
  background(#002966);
  stroke(#b7efff);
  line(x,y,200,150);

  fill(#b7efff);
  ellipse(x,y,13,13);
  ellipse(200,150,13,13);
  if( ! mousePressed )
  {
    float dx=x-200;
    float dy=y-150;
    float len=sqrt(dx*dx+dy*dy);
    float f=(len-100);
    dx/=len;
    dy/=len;
    vx -= f*dx*0.001;
    vy -= f*dy*0.001;
 
    x+=vx;
    y+=vy;
    //x -= dx*(len-100)/len*0.1;
    //y -= dy*(len-100)/len*0.1;
  }
}
void mouseDragged()
{
  x=mouseX; y=mouseY;
}

沒有留言:

張貼留言