DynamicModule[{
width=0.8,(*Size of car*)
height=1,(*Size of car*)
top=8,(*Size of frame*)
bottom=-0.3,(*Size of frame*)
time,
myX,
isCar,
isDead,
isInit=False
},{
L=0;(*Left*)
R=1;(*Right*)

(*Button*)
Button["← move →",If[myX==L,myX=R,myX=L]],
Button["restart",isInit=False],

Animate[
(*Initialize*)
If[isInit==False,
startedTime=t;
myX=L;
factor=0;
bonus=0;
isCar=False;
isDead=False;
isInit=True;
];

(*Generate car*)
If[(isCar==False)&&(isDead==False),
generatedTime=t;
x=RandomInteger[];(*Left or Right*)
y=top;
car={Red,Rectangle[{x,y-height},{x+width,y}]};
isCar=True;
];

(*Forward car*)
If[(isCar==True)&&(isDead==False),
y=top+height-(t-generatedTime);
car={Red,Rectangle[{x,y-height},{x+width,y}]};
];

(*Bonus score*)
If[(myX==x)&&(1.95≤y<2.2)&&(isDead==False),
factor=0.2;
];
If[(myX==x)&&(1.75≤y<1.95)&&(isDead==False),
factor=0.3;
];
If[(myX==x)&&(1.6≤y<1.75)&&(isDead==False),
factor=0.5;
];

(*Check bottom over*)
If[(y<bottom)&&(isDead==False),
isCar=False;
bonus=bonus+((Sqrt[time])+120)*factor;
factor=0;
];

(*Check dead or alive*)
If[(myX==x)&&(0.5<y<1.5)&&(isDead==False),
deadTime=t-startedTime;
isDead=True;
];

(*Over 30sec*)
If[(time>180)&&(isDead==False),
deadTime=t-startedTime;
isDead=True;
];

(*Action*)
If[isDead==True,
(*Condition: Dead*)
time=deadTime;
scoreBoard={
Lighter[Gray],Opacity[.8],Rectangle[{-0,bottom+0.2},{3.8,top-0.2}],
Black,Text[Style["GameOver",Large],{2,top/2+2}],
Black,Text[Style["Base Point: ",Larger],{1.5,top/2}],
Black,Text[Style[IntegerPart[deadTime*10],Larger],{2.5,top/2}],
Black,Text[Style["Bonus Point: ",Larger],{1.5,top/2-1}],
Black,Text[Style[IntegerPart[bonus],Larger],{2.5,top/2-1}],
Black,Text[Style["Total Score: ",Larger],{1.5,top/2-2}],
Black,Text[Style[IntegerPart[deadTime*10]+IntegerPart[bonus],Larger],{2.5,top/2-2}]
},
(*Condition: Alive*)
time=t-startedTime;
scoreBoard={Black,Text[Style["Dodge!",Large],{3,top/2+1}]};
myCar={Blue,Rectangle[{myX,0},{myX+width,height}]};
];

(*Line*)
line={White,Line[{{0.9,bottom},{0.9,top}}]};

(*Timer*)
timerBoard={
Darker[Gray],Rectangle[{2,bottom},{4,top}],
White,Text[Style["Time",Large],{3,bottom+3}],
White,Text[Style[IntegerPart[180-time],Large],{3,bottom+2}]
};

(*Draw Graphics*)
Graphics[{
timerBoard,
Red,car,
myCar,
line,
scoreBoard
},
PlotRange->{{-0.2,4},{bottom,top}},
Background->Gray
],

(*Animation settings*)
{t,0,Infinity},
AnimationRate->6,
AnimationRepetitions->1
](*End of Animation*)
}(*End of expr*)
](*End of DynamicModule*)