PROG6.LST 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. Listing:
  2. 1 MODULE prog6;
  3. 2 (* This program draws patterns on the screen *)
  4. 3 FROM Lib IMPORT RANDOM,RANDOMIZE;
  5. 4 FROM Graph IMPORT Circle,Disc,GraphMode,TextMode,Width,Depth;
  6. 5 IMPORT IO;
  7. 6
  8. 7 TYPE
  9. 8 FunnyType = RECORD
  10. 9 q : INTEGER; (* value *)
  11. 10 d : INTEGER; (* rate of change *)
  12. 11 min : INTEGER;
  13. 12 max : INTEGER;
  14. 13 END;
  15. ***** ^ not supported yet
  16. 14
  17. 15 PROCEDURE init(VAR v:FunnyType);
  18. 16 BEGIN
  19. 17 v.q := v.min;
  20. ***** ^ not supported yet
  21. ***** ^ not supported yet
  22. ***** ^ not supported yet
  23. ***** ^ not supported yet
  24. 18 v.d := INTEGER(RANDOM(v.max-v.min));
  25. ***** ^ not supported yet
  26. ***** ^ not supported yet
  27. ***** ^ not supported yet
  28. ***** ^ not supported yet
  29. ***** ^ not supported yet
  30. ***** ^ not supported yet
  31. ***** ^ not supported yet
  32. 19 END init;
  33. ***** ^ not supported yet
  34. 20
  35. 21 PROCEDURE bounce(VAR v:FunnyType);
  36. 22 (* Update v.q, 'bouncing' when it goes out of range *)
  37. 23 BEGIN
  38. 24 WITH v DO
  39. ***** ^ not supported yet
  40. 25 q := q + d;
  41. ***** ^ not supported yet
  42. ***** ^ not supported yet
  43. ***** ^ not supported yet
  44. 26 IF q < min THEN
  45. ***** ^ not supported yet
  46. ***** ^ not supported yet
  47. 27 q := 2*min-q;
  48. ***** ^ not supported yet
  49. ***** ^ not supported yet
  50. ***** ^ not supported yet
  51. 28 d := -d;
  52. ***** ^ not supported yet
  53. ***** ^ not supported yet
  54. 29 END;
  55. 30 IF q > max THEN
  56. ***** ^ not supported yet
  57. ***** ^ not supported yet
  58. 31 q := 2*max-q;
  59. ***** ^ not supported yet
  60. ***** ^ not supported yet
  61. ***** ^ not supported yet
  62. 32 d := -d;
  63. ***** ^ not supported yet
  64. ***** ^ not supported yet
  65. 33 END;
  66. 34 END;
  67. ***** ^ not supported yet
  68. 35 END bounce;
  69. ***** ^ not supported yet
  70. 36
  71. 37 VAR
  72. 38 x,y : FunnyType;
  73. ***** ^ not supported yet
  74. 39 color,radius : CARDINAL;
  75. 40 BEGIN
  76. 41 RANDOMIZE;
  77. ***** ^ not supported yet
  78. 42 x.max := Width-1; x.min := 0;
  79. ***** ^ not supported yet
  80. ***** ^ not supported yet
  81. ***** ^ not supported yet
  82. ***** ^ not supported yet
  83. ***** ^ not supported yet
  84. 43 y.max := Depth-1; y.min := 0;
  85. ***** ^ not supported yet
  86. ***** ^ not supported yet
  87. ***** ^ not supported yet
  88. ***** ^ not supported yet
  89. ***** ^ not supported yet
  90. 44
  91. 45 IO.WrStr('Press space to continue, any other key to stop');
  92. ***** ^ not supported yet
  93. ***** ^ not supported yet
  94. ***** ^ not supported yet
  95. 46 IO.WrLn;
  96. ***** ^ not supported yet
  97. ***** ^ not supported yet
  98. 47 WHILE NOT IO.KeyPressed() DO
  99. ***** ^ not supported yet
  100. ***** ^ not supported yet
  101. ***** ^ not supported yet
  102. 48 END;
  103. 49
  104. 50 GraphMode;
  105. ***** ^ not supported yet
  106. 51 WHILE IO.RdKey() = ' ' DO
  107. ***** ^ not supported yet
  108. ***** ^ not supported yet
  109. ***** ^ not supported yet
  110. 52 init(x);
  111. ***** ^ not supported yet
  112. ***** ^ not supported yet
  113. 53 init(y);
  114. ***** ^ not supported yet
  115. ***** ^ not supported yet
  116. 54
  117. 55 REPEAT
  118. 56 color := RANDOM(16);
  119. ***** ^ not supported yet
  120. ***** ^ not supported yet
  121. 57 UNTIL color MOD 5 <> 0; (* fill using 2 colors *)
  122. 58
  123. 59 radius := 2 + RANDOM(5);
  124. ***** ^ not supported yet
  125. ***** ^ not supported yet
  126. 60 WHILE NOT IO.KeyPressed() DO
  127. ***** ^ not supported yet
  128. ***** ^ not supported yet
  129. ***** ^ not supported yet
  130. 61 bounce(x);
  131. ***** ^ not supported yet
  132. ***** ^ not supported yet
  133. 62 bounce(y);
  134. ***** ^ not supported yet
  135. ***** ^ not supported yet
  136. 63 Disc(x.q, y.q, radius, color);
  137. ***** ^ not supported yet
  138. ***** ^ not supported yet
  139. ***** ^ not supported yet
  140. ***** ^ not supported yet
  141. ***** ^ not supported yet
  142. ***** ^ not supported yet
  143. 64 Circle(x.q, y.q, radius, color MOD 4);
  144. ***** ^ not supported yet
  145. ***** ^ not supported yet
  146. ***** ^ not supported yet
  147. ***** ^ not supported yet
  148. ***** ^ not supported yet
  149. ***** ^ not supported yet
  150. 65 END;
  151. 66
  152. 67 Disc(0,0,Width+Depth, 0); (* clear screen *)
  153. ***** ^ not supported yet
  154. ***** ^ not supported yet
  155. ***** ^ not supported yet
  156. ***** ^ not supported yet
  157. 68 END;
  158. 69 TextMode;
  159. ***** ^ not supported yet
  160. 70 END prog6.
  161. 71
  162. 89 errors