home *** CD-ROM | disk | FTP | other *** search
- program List10_3;
-
- uses Graph, Mouse, Crt, ProRobot, List10_2;
-
- var
- Arm : RobotArm;
- P0 : Point;
-
- x, y : integer;
-
- GraphDriver : integer;
- GraphMode : integer;
- ErrorCode : integer;
- GlobalAnchorX,
- GlobalAnchorY,
- ArmLength : integer;
-
- begin
- GraphDriver := Detect;
- InitGraph(GraphDriver, GraphMode, 'E:\TP');
- ErrorCode := GraphResult;
- if ErrorCode <> grOK then
- Writeln('Graphics error');
-
- GlobalAnchorX := Round(GetMaxX/3);
- GlobalAnchorY := Round(GetMaxY/2);
- ArmLength := Round(GetMaxY/2.4);
-
- Graph.SetColor(white);
- SetTextStyle( DefaultFont, HorizDir, 2);
- OutTextXY( Round(GetMaxX/1.5), Round(GetMaxY*4/5), 'Robot ''A''' );
- Arm.Init( GlobalAnchorX, GlobalAnchorY, ArmLength,
- 0, true );
- Arm.ShowLimit;
- P0.Init( 0,0);
- if MouseInit = true then
- ;
- MouseShow;
- repeat
- repeat
- until MouseLPressed or KeyPressed;
- if not KeyPressed then
- begin
- P0.Hide;
- repeat
- MouseCoords( x, y );
- until MouseLReleased;
- MouseHide;
- P0.Init( x, y );
- P0.Show;
- Arm.MoveTo( P0 );
- P0.Show; { again in case any part of the box was trashed }
- MouseShow;
- end;
- until KeyPressed;
- end.