Advertisement
Guest User

Untitled

a guest
Mar 19th, 2019
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.03 KB | None | 0 0
  1. #include "library.h"
  2.  
  3. void line_and_turn(int radius, double const pi, double r, double g, double b){
  4. set_pen_color(r, g, b);
  5. double circumference = 2*pi*radius;
  6. double dist_per_degree = circumference / 360;
  7. int counter = 360;
  8. set_heading_degrees(90);
  9. start_shape();
  10. while (counter>0){
  11. note_position();
  12. draw_distance(dist_per_degree);
  13. turn_right_by_degrees(1);
  14. counter = counter - 1;
  15. }
  16. fill_shape();
  17. }
  18.  
  19.  
  20. void moon(double const pi, double r, double g, double b){
  21. int moon_radius = 40;
  22. line_and_turn(moon_radius, pi, r, g, b);
  23. }
  24.  
  25. void night(double const pi){
  26. set_pen_color(0.1, 0.1, 0.1);
  27. fill_rectangle(0, 0, 1000, 800);
  28. move_to(random_in_range(200,800), random_in_range(100,200));
  29. double r = 1.0;
  30. double g = 1.0;
  31. double b = 1.0;
  32. moon(pi,r,g,b);
  33. }
  34.  
  35. void sun(double const pi, double r, double g, double b){
  36. int sun_radius = 75; //radius for sun
  37. line_and_turn(sun_radius, pi, r, g, b);
  38. }
  39.  
  40. void afternoon(double const pi){
  41. set_pen_color(0.10, 0.40, 1.00);
  42. fill_rectangle(0, 0, 1000, 800);
  43. move_to(random_in_range(100, 300), random_in_range(100, 200));
  44. double r = 0.8;
  45. double g = 0.8;
  46. double b = 0.0;
  47. sun(pi,r,g,b);
  48. }
  49.  
  50. void morning(double const pi){
  51. set_pen_color(0.30, 0.50, 0.80);
  52. fill_rectangle(0, 0, 1000, 800); //!!! Needs RGB Values
  53. move_to(random_in_range(600, 800), random_in_range(100, 150));
  54. double r = 1.0;
  55. double g = 1.0;
  56. double b = 0.0;
  57. sun(pi,r,g,b);
  58. }
  59.  
  60. void decide_moon_sun(int time, double const pi){
  61. if (time>=0 && time<=6 || time>=21 && time<24){
  62. night(pi);
  63. }
  64. else if (time >= 7 && time <= 14){
  65. morning(pi);
  66. }
  67. else afternoon(pi);
  68. }
  69.  
  70. void mountains(){
  71. set_pen_color(color::dark_grey);
  72. move_to(0, 480);
  73. int nn = 4;
  74. start_shape();
  75. while (nn>0){
  76. note_position();
  77. set_heading_degrees(90);
  78. turn_right_by_degrees(-random_in_range(30, 35));
  79. draw_distance(random_in_range(200, 300));
  80. note_position();
  81. set_heading_degrees(90);
  82. turn_right_by_degrees(random_in_range(30, 35));
  83. draw_distance(random_in_range(250, 350));
  84. nn = nn - 1;
  85. }
  86. note_position();
  87. draw_to(1000, 800);
  88. note_position();
  89. draw_to(0, 800);
  90. note_position();
  91. draw_to(0, 480);
  92. note_position();
  93. fill_shape();
  94. move_to(0, 550);
  95. }
  96.  
  97. void mountains2(){
  98. set_pen_color(color::grey);
  99. move_to(0, 500);
  100. int m = 6;
  101. start_shape();
  102. while (m > 0){
  103. note_position();
  104. set_heading_degrees(90);
  105. turn_right_by_degrees(-random_in_range(30, 35));
  106. draw_distance(random_in_range(100, 150));
  107. note_position();
  108. set_heading_degrees(90);
  109. turn_right_by_degrees(random_in_range(30, 35));
  110. draw_distance(random_in_range(125, 150));
  111. m = m - 1;
  112. }
  113. note_position();
  114. draw_to(1000, 800);
  115. note_position();
  116. draw_to(0, 800);
  117. note_position();
  118. draw_to(0, 500);
  119. note_position();
  120. fill_shape();
  121. }
  122.  
  123. void log(int xxxxx){
  124. int xxxx = random_in_range(15,25);
  125. int yyyy = random_in_range(100, 150);
  126. set_heading_degrees(0);
  127. set_pen_color(color::brown);
  128. start_shape();
  129. note_position();
  130. draw_distance(yyyy);
  131. note_position();
  132. turn_right_by_degrees(90);
  133. draw_distance(xxxx);
  134. note_position();
  135. turn_right_by_degrees(90);
  136. draw_distance(yyyy);
  137. note_position();
  138. turn_right_by_degrees(90);
  139. draw_distance(xxxx);
  140. note_position();
  141. fill_shape();
  142. move_to(xxxxx + (xxxx / 2), 720+yyyy);
  143. set_pen_width(3);
  144. set_pen_color(color::green);
  145. int kk = 1000;
  146. while (kk > 0){
  147. move_to(xxxxx - 30 + random_in_range(0, 60), 525 + yyyy - random_in_range(0, 100));
  148. draw_point();
  149. kk = kk - 1;
  150. }
  151. }
  152.  
  153. void tree(){
  154. int xxxxx = random_in_range(890, 970);
  155. move_to(xxxxx, 740);
  156. log(xxxxx);
  157. }
  158.  
  159. void grass(){
  160. fill_rectangle(0, 700, 1000, 780, color::dark_green);
  161. }
  162.  
  163. void street(){
  164. fill_rectangle(0, 780, 1000, 800, color::grey);
  165. }
  166.  
  167. void main(){
  168. double const pi = acos(-1.0);
  169. make_window(1000, 800);
  170. cout << "What time of the day is it? (Using 24-hour clock integers)" << endl;
  171. int time;
  172. cin >> time;
  173. decide_moon_sun(time, pi); //sky color
  174. mountains();
  175. mountains2();
  176. grass();
  177. street();
  178. tree();
  179. //background();
  180. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement