home *** CD-ROM | disk | FTP | other *** search
/ Oakland CPM Archive / oakcpm.iso / cpm / graphics / turt100.lbr / TURTLE.LZB / TURTLE.LIB
Encoding:
Text File  |  1986-12-31  |  2.9 KB  |  86 lines

  1. (****************************************************************************)
  2. (*                                                                          *)
  3. (* MODULE: Turtle.Lib 1.00                                                  *)
  4. (* AUTHOR: Tim Meekins                                                      *)
  5. (* DATE:   September 26, 1986                                               *)
  6. (*                                                                          *)
  7. (* This library contains numerous functions and procedures allowing turtle  *)
  8. (* graphics like commands. These routines use a standard cartesian coord-   *)
  9. (* inate system with (0,0) being in the center of the paper. The internal   *)
  10. (* variables keep track of the "turtle's" current x,y position and it's     *)
  11. (* heading. You can also specify whether it will be drawing when it moves   *)
  12. (* with PENUP and PENDOWN procedures. The "turtle" is moved by simply using *)
  13. (* the TMOVE procedure and a distance as a parameter. The TURN procedure    *)
  14. (* will make the "turtle" the number of angle units in the passed parameter.*)
  15. (*                                                                          *)
  16. (* Turtle.lib requires that the host program also include the Diablo.lib    *)
  17. (* module for the basic graphics (printer) commands.                        *)
  18. (*                                                                          *)
  19. (* Ver 1.00  09-26-86  Initial program written.                             *)
  20. (*                                                                          *)
  21. (****************************************************************************)
  22.  
  23.  
  24. { Initialize the Turtle Graphics mode }
  25. { Init_Diablo, need not be called     }
  26. { before accessing this.              }
  27.  
  28. PROCEDURE init_turtle;
  29.   BEGIN
  30.     init_diablo;
  31.     move(250,250);
  32.     t_pen := false;
  33.     t_x := 0;
  34.     t_y := 0;
  35.     t_ang := 0
  36.   END;
  37.  
  38. { The following two procedures set   }
  39. { the drawing mode.                  }
  40.  
  41. PROCEDURE pen_up;
  42.   BEGIN
  43.     t_pen := false
  44.   END;
  45.  
  46. PROCEDURE pen_down;
  47.   BEGIN
  48.     t_pen := true
  49.   END;
  50.  
  51. { These are the moving and drawing procedures }
  52.  
  53. PROCEDURE t_moveto(x,y : integer);
  54.   BEGIN
  55.     CASE t_pen OF
  56.       false : move(x+250,250-y);
  57.       true  : drawto(x+250,250-y)
  58.     END;
  59.     t_x := x; t_y := y
  60.   END;
  61.  
  62. PROCEDURE t_move(distance : integer);
  63.   BEGIN
  64.     t_x := round(t_x + distance * cos(t_ang * 0.01744533));
  65.     t_y := round(t_y + distance * sin(t_ang * 0.01744533));
  66.     t_moveto(t_x,t_y)
  67.   END;
  68.  
  69. { These are the turning procedures }
  70.  
  71. PROCEDURE turnto(angle : integer);
  72.   BEGIN
  73.     WHILE angle > 360 DO
  74.       angle := angle - 360;
  75.     WHILE angle < -360 DO
  76.       angle := angle + 360;
  77.     IF angle < 0 THEN
  78.       angle := 360 - angle;
  79.     t_ang := angle
  80.   END;
  81.  
  82. PROCEDURE turn(angle : integer);
  83.   BEGIN
  84.     turnto(t_ang + angle)
  85.   END;
  86.