금천고등학교 로고이미지

컴퓨터프로그래밍

RSS 페이스북 공유하기 트위터 공유하기 카카오톡 공유하기 카카오스토리 공유하기 네이버밴드 공유하기 프린트하기
벽돌깨기 기본 이미지 활용
작성자 김용남 등록일 22.05.23 조회수 21

int [][]bricks = new int [5][10];

 

int xPos, yPos;

int xSpeed, ySpeed;

 

void setup(){

  size(500, 500);

  xPos = yPos = 10;

  xSpeed = 2;

  ySpeed = 3;

  fill(100);

  stroke(100);

  for(int i = 0; i < 5; i++){

    for(int j = 0; j < 10; j++){

      bricks[i][j] = 1;

    }

  }

}

 

void draw(){

  background(0);

  stroke(255);

  ellipse(xPos, yPos, 20, 20);

  

  for(int i = 0; i < 5; i++){

    for(int j = 0; j < 10; j++){

 

      fill(255);

      rect(j*50, i*20, 50, 20);

    }

  }

  

  stroke(255);

  strokeWeight(5);

  line(mouseX-50, height - 50, mouseX + 50 , height - 50 );

  xPos += xSpeed;

  yPos += ySpeed;

  if(xPos < 10 || xPos > width -10) xSpeed *= (-1);

  if(yPos < 10 || yPos > height -60 && xPos > mouseX-50 && xPos < mouseX+50) ySpeed *= (-1);

}

이전글 벽돌깨기 예제
다음글 글자의 움직임 프로세싱 예제