私はProcessing3を使って私の大学のプロジェクトのゲームを作っています。このゲームは、x軸上を移動するマウスで制御する自動車で構成されています。私は人とコインを加えて、x軸上を上下に動いています。長方形が動画に当たったときにスコアを上げるにはどうすればよいですか? 矩形私が作成した車の一部画像が道路上を上下に動いているときに、スコアが上がるようにします。私は正直に言えば、私の周りに頭を浮かべることができないので、私はできるだけ多くの助けを感謝します。スコアで問題を解決しようとしたところを強調しました。長方形が動画に当たったときにスコアを上げるにはどうすればよいですか?
PImage sun,person1,person2,person3,person4,**coin**;
int x,y;
float ypos=0;
float ypos2=4;
**int coin_x,coin_y,coin_count;
int score=0,lives=3;**
void setup()
{
size(1000,585);
person1 = loadImage("person1.png");
sun = loadImage("sun.png");
**coin = loadImage("coin.png");**
person2 = loadImage("person2.png");
person3 = loadImage("person3.png");
person4 = loadImage("person4.png");
x=width/2;
y=height/2;
}
void draw()
{
background(170,200,255);
image(sun,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);
//vvvvvvvvv The car vvvvvvvvvvv
**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);**
//^^^^^^^^^The car^^^^^^^^^
image(person4,(-frameCount%300)*10+2500,250+sin(ypos)*100,120,120);
ypos +=0.01;
image(person3,(-frameCount%450)*5+2000,400+sin(ypos)*140,120,120);
ypos +=0.01;
image(person1,(-frameCount%300)*5+1000,300+sin(ypos)*50,120,120);
ypos +=0.01;
**image(coin,coin_x+(-frameCount%100)*20+1000,coin_y+300-sin(ypos2)*130,50,50);**
ypos2 +=0.05;
image(person2,(-frameCount%400)*5+1600,250-sin(ypos)*100,120,120);
ypos +=0.08;
**image(coin,coin_x+(-frameCount%300)*20+1900,coin_y+300+sin(ypos2)*130,50,50);
ypos2 +=0.05;**
**if((coin_x>10)&&(coin_x<10))
{
if(abs((coin_y+10)-(mouseY+0))<25)
{
coin_count++;
}
}**
**textSize(30);
fill(0);
text("Score:"+coin_count,0,25);**
}
クロスポスト間をリンクしてください。この質問もここに掲載されています:https://forum.processing.org/two/discussion/25682/how-can-i-make-the-score-go-up-when-a-rectangle-hits-a-動画像 –