[Start a New Application. Drop two TShape Components on the main form. Set Shape1's
brush to black, Shape2's to red. Set their width and height to 16. Set the forms
clientwidth to 320 and clientheight to 200. Double-Click the form to create an
FormCreate handler. Add: ]
randomize;
Shape2.Left:=Random(304); { ball left position }
Shape2.Top:=Random(184); { ball top position }
Shape1.Left:=Random(304); { hole left position }
Shape1.Top:=Random(184); { hole top position }
[Double-Click the forms Keypress event in the object inspector to create an keypress
handler. Add: ]
if key='e' then shape2.top:=shape2.top-1; { move ball up }
if key='d' then shape2.left:=shape2.left+1; { move ball right }
if key='x' then shape2.top:=shape2.top+1; { move ball down }
if key='s' then shape2.left:=shape2.left-1; { move ball left }
if (shape1.left=shape2.left) and (shape1.top=shape2.top) then close;