##程式碼
PImage starS, winP, loseP, starT, ansOne, falloW, nexT, agaiN, ansTwo;
int Z,zZ;
int D1=0, D2=6;
int j=0, W;
int clickCount = 0;
int []Ponx= { 100, 400, 250, 100, 400};
int []Ponx2= { 125, 375, 75, 425, 250};
int []Pony= { 400, 400, 275, 150, 150};
int []Pony2= { 425, 425, 175, 175, 75};
int []PPx= { 125, 425, 275, 125, 425};
int []PPx2= { 250, 500, 200, 550, 375};
int []PPy= { 425, 425, 300, 175, 175};
int []PPy2= { 550, 550, 300, 300, 350};
int []x= { 6, 6, 6, 6, 6, 6, 6};
int []x2= { 6, 6, 6, 6, 6, 6};
int []ans1= { 0, 2, 4, 1, 2, 3, 0};
int []ans5= { 0, 4, 1, 2, 3, 0};
int []ans2= { 0, 2, 1, 4, 2, 3, 0};
int []ans6= { 0, 3, 2, 1, 4, 0};
int []ans3= { 0, 3, 2, 4, 1, 2, 0};
int []ans4= { 0, 3, 2, 1, 4, 2, 0};
void setup()
{
size(900, 600);
background(24, 20, 90);
starS=loadImage("http://i.imgur.com/
winP=loadImage("http://i.imgur.com/Sx6NCzf.jpg");
loseP=loadImage("http://i.imgur.com/
ansOne=loadImage("http://i.imgur.com/HRVkRHp.png");
starT=loadImage("http://i.imgur.com/
falloW=loadImage("http://i.imgur.com/oxcZTaE.png");
nexT=loadImage("http://i.imgur.com/4hb4Cln.png");
agaiN=loadImage("http://i.imgur.com/BdxdTvl.png");
ansTwo=loadImage("http://i.imgur.com/tFNyu4o.png");
sett1();
}
void sett1()
{
image(starS, Ponx[0], Pony[0], 50, 50);
image(starS, Ponx[1], Pony[1], 50, 50);
image(starS, Ponx[2], Pony[2], 50, 50);
image(starS, Ponx[3], Pony[3], 50, 50);
image(starS, Ponx[4], Pony[4], 50, 50);
image(starT, 55, 455, 150, 80);
image(falloW, 600, 190, 200, 40);
image(ansOne, 600, 250, 200, 200);
}
void sett2()
{
image(starS, Ponx2[0], Pony2[0], 50, 50);
image(starS, Ponx2[1], Pony2[1], 50, 50);
image(starS, Ponx2[2], Pony2[2], 50, 50);
image(starS, Ponx2[3], Pony2[3], 50, 50);
image(starS, Ponx2[4], Pony2[4], 50, 50);
image(starT, 55, 500, 150, 80);
image(falloW, 600, 190, 200, 40);
image(ansTwo, 600, 250, 200, 200);
}
void mouseClicked()
{
if(mouseButton==LEFT)
{
if (Ponx[0]<=mouseX&&mouseX<=Ponx
{
Z=0;
}
else if (Ponx[1]<=mouseX&&mouseX<=Ponx
{
Z=1;
}
else if (Ponx[2]<=mouseX&&mouseX<=Ponx
{
Z=2;
}
else if (Ponx[3]<=mouseX&&mouseX<=Ponx
{
Z=3;
}
else if (Ponx[4]<=mouseX&&mouseX<=Ponx
{
Z=4;
}
x[clickCount]=Z;
clickCount++;
println("====");
for (j=0;j < x.length; j++)
{
println(x[j]);
}
if (clickCount > 6)
{
check();
}
}
else if(mouseButton==RIGHT)
{
if (450<=mouseX&&mouseX<=600&&150
{
background(24, 20, 90);
sett2();
}
else if (450<=mouseX&&mouseX<=600&&450
{
background(24, 20, 90);
sett1();
}
}
if (D1!=6)
{
D2=Z;
draw();
D1=D2;
D2=6;
}
}
void draw()
{
if (D1==0 && D2==1 || D1==1 && D2==0)
line(PPx[0], PPy[0], PPx[1], PPy[1]);
else if (D1==0 && D2==3 ||D1==3 && D2==0 )
line(PPx[0], PPy[0], PPx[3], PPy[3]);
else if (D1==2 && D2==0 ||D1==0 && D2==2 )
line(PPx[0], PPy[0], PPx[2], PPy[2]);
else if (D1==1 && D2==2 ||D1==2 && D2==1 )
line(PPx[1], PPy[1], PPx[2], PPy[2]);
else if (D1==1 && D2==4 ||D1==4 && D2==1 )
line(PPx[1], PPy[1], PPx[4], PPy[4]);
else if (D1==2 && D2==3 ||D1==3 && D2==2 )
line(PPx[2], PPy[2], PPx[3], PPy[3]);
else if (D1==2 && D2==4 ||D1==4 && D2==2 )
line(PPx[2], PPy[2], PPx[4], PPy[4]);
else if (D1==3 && D2==4 ||D1==4 && D2==3 )
line(PPx[3], PPy[3], PPx[4], PPy[4]);
}
void check()
{
for (int i=0;i<7;i++)//check ans1
{
if (x[i]==ans1[i])
W=1;
else
{
W=0;
i=7;
}
}
if (W==0) //not ans1,check ans2
{
for (int i=0;i<7;i++)//check ans2
{
if (x[i]==ans2[i])
W=1;
else
{
W=0;
i=7;
}
}
if (W==0) //not ans2,check ans3
{
for (int i=0;i<7;i++)//check ans3
{
if (x[i]==ans3[i])
W=1;
else
{
W=0;
i=7;
}
}
if (W==0) //not ans3,check ans4
{
for (int i=0;i<7;i++)//check ans4
{
if (x[i]==ans4[i])
W=1;
else
{
W=0;
i=7;
}
}
if (W==0) //not ans4,All not end
{
lose();
}
else if (W==1) //ans4 OK
{
win();
}
}
else if (W==1) //ans3 OK
{
win();
}
}
else if (W==1) //ans2 OK
{
win();
}
}
else if (W==1) //ans1 OK
{
win();
}
}
void win()
{
image(winP, 100, 150, 350, 350);
image(nexT, 450, 150, 150, 80);
}
void lose()
{
image(loseP, 100, 150, 350, 350);
image(agaiN, 450, 450, 150, 80);
}
沒有留言:
張貼留言