(*画面の座標設定*)
WSizeX=300;
WSizeY=200;

(*----- 変数定義 -----*)
Array[X,3];
Array[Y,21];
For[i=1,i≤3,i++,X[i]=i*120-240];
For[i=1,i≤21,i++,Y[i]=500];

Array[Speed,12];
For[i=1,i≤12,i++,Speed[i]=50];
SliderY1=0;
SliderY2=700;

Array[CNum,3];
For[i=1,i≤3,i++,CNum[i]=i*7-6];

Array[Flag,6];
For[i=1,i≤5,i++,Flag[i]=0];

(*ボタンの影*)
Button1=Disk[{-120,-100},24];
Button1a=Disk[{-120,-105},25];
Button2=Disk[{0,-100},24];
Button2a=Disk[{0,-105},25];
Button3=Disk[{120,-100},24];
Button3a=Disk[{120,-105},25];
ButtonR=Disk[{220,-100},45];
ButtonRa=Disk[{220,-110},50];

(*難易度変換ボタン*)
ButtonE=Rectangle[{-270,35},{-215,90}];
ButtonM=Rectangle[{-270,-35},{-215,20}];
ButtonH=Rectangle[{-270,-105},{-215,-50}];

(*スロット部分の枠*)
Frame1=Rectangle[{-190,-40},{190,-30}];
Frame2=Rectangle[{-190,-40},{-180,100}];
Frame3=Rectangle[{180,-40},{190,100}];
Frame4=Rectangle[{-190,90},{190,100}];

(*テキスト*)
Hedder="★★★★★ Slot ★★★★★";
SpText="";

(*----- ゲーム開始から以下を実行 -----*)
Dynamic[
Refresh[
(*----- 計算処理 -----*)
If[Flag[1]==0,
If[CNum[1]<=7,{
Y[CNum[1]]=500,CNum[1]++,If[CNum[1]==8,Y[1]=30,Y[CNum[1]]=30]},
CNum[1]=1];
];
If[Flag[2]==0,
If[CNum[2]≤14,{
Y[CNum[2]]=500,CNum[2]++,If[CNum[2]==15,Y[8]=30,Y[CNum[2]]=30]},
CNum[2]=8];
];
If[Flag[3]==0,
If[CNum[3]≤21,{
Y[CNum[3]]=500,CNum[3]++,If[CNum[3]==22,Y[15]=30,Y[CNum[3]]=30]},
CNum[3]=15];
];

If[Flag[1]==0&&Flag[2]==0&&Flag[3]==0,SpText=""];

If[Flag[1]==1&&Flag[2]==1&&Flag[3]==1,{
For[i=1,i≤7,i++,{
If[Y[i]==30&&Y[i+7]==30&&Y[i+14]==30,{SpText="Great!",key=i}
]}]}];

Sound[{SoundNote["C"],SoundNote["G"]}];
(*難易度によるpause時間*)
If[Flag[4]==1,For[i=0,i<50000,i++]];
If[Flag[4]==2,For[i=0,i<100000,i++]];

ActiveButton=Rectangle[{-270,Flag[4]*70-100},{-220,Flag[4]*70-50}];

(*----- 画面表示 -----*)
Graphics[
{
(*数字表示部分のディスプレイ*)
{White,Rectangle[{-180,-30},{180,90}]},

(*左側の数字*)
{Text[Style["1",FontSize->50],{X[1],Y[1]}]},{Text[Style["2",FontSize->50],{X[1],Y[2]}]},{Text[Style["3",FontSize->50],{X[1],Y[3]}]},{Text[Style["4",FontSize->50],{X[1],Y[4]}]},{Text[Style["5",FontSize->50],{X[1],Y[5]}]},{Text[Style["6",FontSize->50],{X[1],Y[6]}]},{Red,Text[Style["7",FontSize->50],{X[1],Y[7]}]},

(*真ん中の数字*)
{Text[Style["1",FontSize->50],{X[2],Y[8]}]},{Text[Style["2",FontSize->50],{X[2],Y[9]}]},{Text[Style["3",FontSize->50],{X[2],Y[10]}]},{Text[Style["4",FontSize->50],{X[2],Y[11]}]},{Text[Style["5",FontSize->50],{X[2],Y[12]}]},{Text[Style["6",FontSize->50],{X[2],Y[13]}]},{Red,Text[Style["7",FontSize->50],{X[2],Y[14]}]},

(*右側の数字*)
{Text[Style["1",FontSize->50],{X[3],Y[15]}]},{Text[Style["2",FontSize->50],{X[3],Y[16]}]},{Text[Style["3",FontSize->50],{X[3],Y[17]}]},{Text[Style["4",FontSize->50],{X[3],Y[18]}]},{Text[Style["5",FontSize->50],{X[3],Y[19]}]},{Text[Style["6",FontSize->50],{X[3],Y[20]}]},{Red,Text[Style["7",FontSize->50],{X[3],Y[21]}]},

(*スロット部分の枠*)
{Brown,Frame1,Frame2,Frame3,Frame4},

(*ストップボタン：左*)
{Red,Button1a},
{Pink,Button1},
{Red,Button[Disk[{-120,-100},20],{
EmitSound[Sound[SoundNote["C",0.08]]],
Flag[1]=1}]},
(*ストップボタン：真ん中*)
{Red,Button2a},
{Pink,Button2},
{Red,Button[Disk[{0,-100},20],{
EmitSound[Sound[SoundNote["C",0.08]]],
Flag[2]=1}]},
(*ストップボタン：右*)
{Red,Button3a},
{Pink,Button3},
{Red,Button[Disk[{120,-100},20],{
EmitSound[Sound[SoundNote["C",0.08]]],
Flag[3]=1}]},

(*リセットボタン*)
{Red,ButtonRa},
{Pink,ButtonR},
{Red,Button[Disk[{220,-100},40],{
EmitSound[Sound[{SoundNote["G",0.05],SoundNote["C",0.05]}]],
For[i=1,i≤3,i++,Flag[i]=0]}]},
{White,Text[Style["Reset",FontSize->15,FontFamily->"Helvetica",Bold],{220,-WSizeY+100}]},

{LightGray,ButtonE},
{Opacity[1],Gray,Button[Rectangle[{-270,40},{-220,90}],Flag[4]=2]},
{Yellow,Text[Style["易",FontSize->20,Bold],{-245,110}]},
{LightGray,ButtonM},
{Gray,Button[Rectangle[{-270,-30},{-220,20}],Flag[4]=1]},
{LightGray,ButtonH},
{Gray,Button[Rectangle[{-270,-100},{-220,-50}],Flag[4]=0]},{Yellow,Text[Style["難",FontSize->20,Bold],{-245,-125}]},
{Black,ActiveButton},

(*テキストの表示*)
{Blue,Text[Style[Hedder,FontSize->20,FontFamily->"Helvetica",Bold],{0,WSizeY-30}]},
{Blue,Text[Style[SpText,FontSize->20,FontFamily->"Helvetica"],{0,WSizeY-65}]}
},
Background->Orange,
PlotRange->{{-WSizeX,WSizeX},{-WSizeY,WSizeY}},
Frame->False,
FrameTicks->None
],

UpdateInterval->3
]
]

Value[key]

Head[key]

(*画面の座標設定*)
WSizeX1=600;
WSizeY1=600;

Array[Opa,7];
For[i=1,i≤7,i++,Opa[i]=1];

poly1=Polygon[{{Sqrt[3]*100,500},{0,400},{0,200},{Sqrt[3]*100,100},{2*Sqrt[3]*100,200},{2*Sqrt[3]*100,400}}];
poly2=Polygon[{{2*Sqrt[3]*100,200},{Sqrt[3]*100,100},{Sqrt[3]*100,-100},{2*Sqrt[3]*100,-200},{3*Sqrt[3]*100,-100},{3*Sqrt[3]*100,100}}];
poly3=Polygon[{{Sqrt[3]*100,-100},{0,-200},{0,-400},{Sqrt[3]*100,-500},{2*Sqrt[3]*100,-400},{2*Sqrt[3]*100,-200}}];
poly4=Polygon[{{-Sqrt[3]*100,-100},{-2*Sqrt[3]*100,-200},{-2*Sqrt[3]*100,-400},{-Sqrt[3]*100,-500},{0,-400},{0,-200}}];
poly5=Polygon[{{-2*Sqrt[3]*100,200},{-3*Sqrt[3]*100,100},{-3*Sqrt[3]*100,-100},{-2*Sqrt[3]*100,-200},{-Sqrt[3]*100,-100},{-Sqrt[3]*100,100}}];
poly6=Polygon[{{-Sqrt[3]*100,500},{0,400},{0,200},{-Sqrt[3]*100,100},{-2*Sqrt[3]*100,200},{-2*Sqrt[3]*100,400}}];
poly7=Polygon[{{0,200},{-Sqrt[3]*100,100},{-Sqrt[3]*100,-100},{0,-200},{Sqrt[3]*100,-100},{Sqrt[3]*100,100}}];

fin={
{Orange,Thickness[.2],Circle[{200,200},30]},
{Orange,Polygon[{{-300,-260},{-260,-300},{150,110},{110,150}}]},
{Orange,Polygon[{{-200,-300},{-150,-250},{-200,-200},{-250,-250}}]},
{Orange,Polygon[{{-120,-220},{-60,-160},{-110,-110},{-170,-170}}]}
};

(*----- ゲーム開始から以下を実行 -----*)
Dynamic[
Refresh[
Opa[key]=0;
Graphics[
{
{Orange,fin},
{Black,Text[Style["Congratulations!",FontSize->20,FontFamily->"Helvetica",Bold],{0,0}]},

(*one*){Opacity[Opa[1]],Purple,poly1},
(*two*){Opacity[Opa[2]],Red,poly2},
(*three*){Opacity[Opa[3]],Orange,poly3},
(*four*){Opacity[Opa[4]],Yellow,poly4},
(*five*){Opacity[Opa[5]],Green,poly5},
(*six*){Opacity[Opa[6]],Blue,poly6},
(*seven*){Opacity[Opa[7]],White,poly7},

(*text*)
{Opacity[Opa[1]],Black,Text[Style["1",FontSize->70,FontFamily->"Helvetica",Bold],{Sqrt[3]*100,300}]},
{Opacity[Opa[2]],Black,Text[Style["2",FontSize->70,FontFamily->"Helvetica",Bold],{2*Sqrt[3]*100,0}]},
{Opacity[Opa[3]],Black,Text[Style["3",FontSize->70,FontFamily->"Helvetica",Bold],{Sqrt[3]*100,-300}]},
{Opacity[Opa[4]],Black,Text[Style["4",FontSize->70,FontFamily->"Helvetica",Bold],{-Sqrt[3]*100,-300}]},
{Opacity[Opa[5]],Black,Text[Style["5",FontSize->70,FontFamily->"Helvetica",Bold],{-2*Sqrt[3]*100,0}]},
{Opacity[Opa[6]],Black,Text[Style["6",FontSize->70,FontFamily->"Helvetica",Bold],{-Sqrt[3]*100,300}]},
{Opacity[Opa[7]],Black,Text[Style["7",FontSize->70,FontFamily->"Helvetica",Bold],{0,0}]}
},
PlotRange->{{-WSizeX1,WSizeX1},{-WSizeY1,WSizeY1}},
Frame->False,
FrameTicks->None
],
UpdateInterval->10
]
]