processing pingpong |
|||||
---|---|---|---|---|---|
작성자 | 김용남 | 등록일 | 18.11.02 | 조회수 | 105 |
int x = 150; int xCir = 10; int yCir = 10; int xDir = -2; int yDir = -3; void setup(){ size(400,400); } void draw(){ background(0); noStroke(); ellipse(xCir,yCir,20,20); xCir+=xDir; yCir+=yDir; if((x>0)&&(x<350)){ if(keyPressed&&(key==CODED)){ if(keyCode==LEFT) { x-=1; } else if(keyCode==RIGHT){ x+=1; } } rect(x,340,100,15); if(x==0){ x=x+1; } if(x==300){ x=x-1; } } if(xCir<10||xCir>width-10)xDir*=-1; if(yCir<0) yDir*=-1; if(yCir>height-70 && xCir>=x && xCir<=x+250) { yDir*=-1; } }
|
이전글 | 엑셀2급A형 소스 및 문제 |
---|---|
다음글 | processing text |