DynamicModule[{
gameFlag,
shTime,
stFlag=1,
shFlag,
reFlag=1,
coFlag,
count,
},
{

(*Reset&NextGame*)
Button[Reset,{stFlag=1,reFlag=1}],
Button[Shoot,shFlag=1],
Animate[
If[stFlag==1,
ball = Disk[{1,2},0.2];
tY = RandomReal[{1,4}];
target = Rectangle[{8.5,tY},{9,tY+1}];
ground =  Line[{{0,1},{10,1}}];
gameFlag=0;
shFlag=0;
shTime=0;
coFlag=0;
(*Reset*)
If[reFlag==1,
count=0;
over=Text[Style["",Large],{5,5}];
reFlag=0;
];

stFlag=0;
];

(*PushShoot*)
If[shFlag==1&&gameFlag==0,
shTime=t;
gameFlag=1;
coFlag=1;
];

(*Orbit*)
If[shFlag==1&&gameFlag==1,
bX = 10*Cos[rad]*(t-shTime);
bY = 10*Sin[rad]*(t-shTime)-1/2*9.8*(t-shTime)^2;
ball = Disk[{1+bX,2+bY},0.2];
];


(*当たり判定*)
If[(1+bX+0.3>8.5)&&(1+bX-0.3<9)&&(2+bY+0.3>tY)&&(2+bY-0.3<tY+1),
If[coFlag==1,
count++;
];
stFlag=1;
];

(*GAMEOVER*)
If[bX>10&&bY<0&&gameFlag==1,
over=Text[Style["GAMEOVER",Red,Large],{5,5}];
];

(*当たった回数の表示*)
score=Text[Style["SCORE:",Large],{2,7}];
text=Text[Style[count,Large],{4,7}];

(*描画*)
Graphics[{ball,ground,target,score,text,over},PlotRange->{{0,10},{0,8}}],
{t,0,Infinity},
{rad,0,Pi/2},
AnimationRate->1,
AnimationRepetitions->1,
AnimationRunning->False
]}]