금천고등학교 로고이미지

컴퓨터프로그래밍

RSS 페이스북 공유하기 트위터 공유하기 카카오톡 공유하기 카카오스토리 공유하기 네이버밴드 공유하기 프린트하기
팩맨
작성자 박세빈 등록일 21.07.28 조회수 56

int x1 = int(random(width));

int y1 = int(random(height));

 

int xspeed1 = 2;

int yspeed1 = 1;

 

int size = 50;

 

void setup() {

   size(640, 480);

}

 

void draw() {

   println(frameCount);

   background(0);

   move();

   display();

}

 

void move(){

   x1 = x1 + xspeed1; 

   y1 = y1 + yspeed1;

    if(x1 < 0 || x1 > 640){

    xspeed1 = -xspeed1;   

  }

  if(y1 < 0 || y1 > 480){

    yspeed1 = -yspeed1;   

  }

}

 

void display() {

  fill(random(255), random(255), random(255));     

 

  if(frameCount % 60 < 30){

    arc(x1, y1, size, size, 0.5, 5.78);

  } else {

    arc(x1, y1, size, size, 0.1, 6.18);    

  }

}

이전글 클래스 팩맨
다음글 기능 단위 팩맨