0
나는 대학 프로젝트를 위해 게임을 만들고 있는데 도움이 필요하다. 나는 당신이 마우스로 y 좌표에 차를 조종하는 게임을 만들고있다. 당신은 사람들을 피하고 y 좌표에서 움직이는 동전을 수집해야합니다. 처리 3에 내 차의 사각형 부분과의 충돌시 사람과 동전의 이미지를 사라지게하십시오. 당신은 직사각형 - 사각형 충돌 감지를 수행 할 필요가가공시 직사각형과의 충돌로 이미지가 사라지게하는 방법은 무엇입니까?
PImage img,img1,img2,img3,img4,img5;
int x,y;
float ypos=0;
float ypos2=4;
void setup()
{
size(1000,585);
img = loadImage("person1.png");
img1 = loadImage("sun.png");
img2 = loadImage("coin.png");
img3 = loadImage("person2.png");
img4 = loadImage("person3.png");
img5 = loadImage("person4.png");
x=width/2;
y=height/2;
}
void draw()
{
background(170,200,255);
image(img1,720,-30,160,160);
fill(255,240,50);
ellipse(800,50,85,85);
fill(200,255,150);
rect(0,200,1000,400);
fill(0,0,0);
rect((-frameCount%200)*10+1000,130,90,70);
rect((-frameCount%200)*10+1090,100,50,100);
rect((-frameCount%200)*10+1500,130,90,70);
rect((-frameCount%200)*10+1900,100,50,100);
fill(200,200,200);
rect(0,250,1000,90);
fill(200,200,200);
rect(0,350,1000,90);
fill(200,200,200);
rect(0,450,1000,90);
fill(255,100,100);
rect(0,mouseY+0,200,80);
fill(0);
ellipse(50,mouseY+60,60,60);
fill(0);
ellipse(150,mouseY+60,60,60);
fill(100);
ellipse(50,mouseY+60,40,40);
fill(100);
ellipse(150,mouseY+60,40,40);
fill(255,100,100);
arc(100,mouseY+0,160,150,PI,TWO_PI);
fill(160,210,300);
arc(100,mouseY+0,130,130,PI,TWO_PI);
fill(255,100,100);
rect(95,mouseY+0,10,-75);
fill(0);
rect(99,mouseY+0,2,80);
image(img5,(-frameCount%300)*10+2500,250+sin(ypos)*100,120,120);
ypos +=0.01;
image(img4,(-frameCount%450)*5+2000,400+sin(ypos)*140,120,120);
ypos +=0.01;
image(img,(-frameCount%300)*5+1000,300+sin(ypos)*50,120,120);
ypos +=0.01;
image(img2,(-frameCount%100)*20+1000,300-sin(ypos2)*130,50,50);
ypos2 +=0.05;
image(img3,(-frameCount%400)*5+1600,250-sin(ypos)*100,120,120);
ypos +=0.08;
image(img2,(-frameCount%300)*20+1900,300+sin(ypos2)*130,50,50);
ypos2 +=0.05;
}
내 질문에 답변 해 주셔서 감사합니다.하지만이를 코드에 어떻게 추가해야할지 모르겠습니까? 정확하게 이것을 추가해야하는 위치를 알려주시겠습니까? 내 코드에 추가해야 할 정보가 더 있습니까? 사각형이 맞은 후에 이미지를 멈추게하려면 어떻게해야합니까? 어떤 종류의 'stop'명령이 있습니까? –