วันอังคารที่ 24 กันยายน พ.ศ. 2556

-Class UFO-



void setup ()
{
  size(300, 300);
}

Ufo u = new Ufo (50, 50);
int check=0;

void draw()
{
  background(0);  
  u.display();
}

class Ufo
{
  int x, y, z;

  Ufo(int a, int b)
  {

    this.x=a;
    this.y=b;
    this.z=0;
  }

  void display() {
    drawUFO();
    move();
  }
  void move(){
    if(this.x<270&&this.y==50){
      this.x=this.x+1;
   
    }
    if(this.x==270&&this.y<270){
     this.y=this.y+1;
   
    }
    if(this.x>30&&this.y==270){
     this.x=this.x-1;
    }
    if(this.x==30&&this.y>50){
      this.y=this.y-1;
    }
 
  }
  void drawUFO() {
   fill(250,255,0);
   triangle(x,y,x-15,y+30,x+15,y+30);
   fill(150);
   ellipse(x,y,30,30);
   fill(30, 144 ,255);
   ellipse(x,y+5,50,15);
 
  }
}

ไม่มีความคิดเห็น:

แสดงความคิดเห็น