Advertisement
Guest User

assignment 9

a guest
Dec 1st, 2010
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 16.84 KB | None | 0 0
  1. // Course:          CS 10 <FALL 2010>
  2. //
  3. // First Name:      JOSHUA
  4. // Last Name:       LEE
  5. // Course username: <jlee119>
  6. // email address:   <jlee119@ucr.edu>
  7. //
  8. // Lecture Section: <001>
  9. // Lab Section:     <023>
  10. // TA:              Emine Celikkaya
  11. //
  12. // Assignment:      <ASSN#8>
  13. //
  14. // I hereby certify that the code in this file
  15. // is ENTIRELY my own original work.
  16. //
  17. // =================================================================
  18.  
  19. #include "instinct.h"
  20. #include <vector>
  21. #include <string>
  22.  
  23. const double FROG_SIZE = 5.0;
  24. const double XMOVE = FROG_SIZE;
  25. const double YMOVE = FROG_SIZE;
  26.  
  27. const int LIVES = 3;
  28. const int FROG_WAIT = 100;
  29. const int FRAME_WAIT = 20;
  30.  
  31. const double PAD_H = FROG_SIZE;
  32. const double PAD_W = FROG_SIZE;
  33. const double PAD_YPOS = FROG_SIZE * 13;
  34. const double PAD_XPOS1 = FROG_SIZE * 5;
  35. const double PAD_XPOS2 = FROG_SIZE * 14;
  36.  
  37. const double TRUCK_H = FROG_SIZE;
  38. const double TRUCK_W = FROG_SIZE * 4;
  39. const double TRUCK_LANE1 = FROG_SIZE * 2;
  40. const double TRUCK_LANE2 = FROG_SIZE * 4;
  41. const double TRUCK_LANE1_SPEED = TRUCK_W * 0.03;
  42. const double TRUCK_LANE2_SPEED = TRUCK_W * 0.02;
  43. const double TRUCK_LANE1_START = 0;
  44. const double TRUCK_LANE2_START = 4;
  45.  
  46. const double CAR_H = FROG_SIZE;
  47. const double CAR_W = FROG_SIZE * 2;
  48. const double CAR_LANE1 = FROG_SIZE;
  49. const double CAR_LANE2 = FROG_SIZE * 3;
  50. const double CAR_LANE3 = FROG_SIZE * 5;
  51. const double CAR_LANE1_SPEED = CAR_W * 0.01;
  52. const double CAR_LANE2_SPEED = CAR_W * 0.03;
  53. const double CAR_LANE3_SPEED = CAR_W * 0.02;
  54. const double CAR_LANE1_START = 2;
  55. const double CAR_LANE2_START = 3;
  56. const double CAR_LANE3_START = 1;
  57.  
  58. const double LOG_H = FROG_SIZE;
  59. const double LOG_W = FROG_SIZE * 6;
  60. const double LOG_LANE1 = FROG_SIZE * 8;
  61. const double LOG_LANE2 = FROG_SIZE * 9;
  62. const double LOG_LANE3 = FROG_SIZE * 11;
  63. const double LOG_LANE1_SPEED = LOG_W * 0.015;
  64. const double LOG_LANE2_SPEED = LOG_W * 0.005;
  65. const double LOG_LANE3_SPEED = LOG_W * 0.01;
  66. const double LOG_LANE1_START = 0;
  67. const double LOG_LANE2_START = 4;
  68. const double LOG_LANE3_START = 2;
  69.  
  70. const double TURTLE_H = FROG_SIZE;
  71. const double TURTLE_W = FROG_SIZE * 2;
  72. const double TURTLE_LANE1 = FROG_SIZE * 7;
  73. const double TURTLE_LANE2 = FROG_SIZE * 10;
  74. const double TURTLE_LANE3 = FROG_SIZE * 12;
  75. const double TURTLE_LANE1_SPEED = TURTLE_W * 0.01;
  76. const double TURTLE_LANE2_SPEED = TURTLE_W * 0.03;
  77. const double TURTLE_LANE3_SPEED = TURTLE_W * 0.005;
  78. const double TURTLE_LANE1_START = 1;
  79. const double TURTLE_LANE2_START = 3;
  80. const double TURTLE_LANE3_START = 5;
  81.  
  82. const int OBJECT_GAP = FROG_SIZE * 6;
  83. const int TRUCK_GAP = OBJECT_GAP + TRUCK_W;
  84. const int CAR_GAP = CAR_W * 3;
  85. const int LOG_GAP = OBJECT_GAP + LOG_W;
  86. const int TURTLE_GAP = OBJECT_GAP + TURTLE_W;
  87.  
  88. const Point  FROG_START = Point(45, 0);
  89.  
  90. const double XPOS_OFFSET_FROG_MSG = 5.0;
  91. const double YPOS_OFFSET_FROG_MSG = 3.0;
  92.  
  93. const Message MSG_LIVES_LEFT = Message(Point(5, -3),
  94.                                             "Lives left:",
  95.                                             BLACK);
  96.  
  97. void output_splat( Point frog );
  98. void move_frog( Rect &frog, Timer &frog_tmr );
  99. void move_trucks(vector<Rect> &trucks);
  100. void move_cars(vector<Rect> &cars);
  101. void move_logs(vector<Rect> &logs);
  102. void move_turtles(vector<Rect> &turtles);
  103. Rect create_truck(double x, double y);
  104. Rect create_car(double x, double y);
  105. Rect create_log(double x, double y);
  106. Rect create_turtle(double x, double y);
  107. void init_frog(Rect &frog);
  108. void init_trucks(vector<Rect> &trucks);
  109. void init_cars(vector<Rect> &cars);
  110. void init_logs(vector<Rect> &logs);
  111. void init_turtles(vector<Rect> &turtles);
  112. void init_pads(vector<Rect> &pads);
  113. void output_result(Point frog, string text);
  114. bool collision(Rect r1, vector<Rect> &rectangles);
  115. bool inside(Point p, Rect r);
  116. bool is_border_overlap(Point p1, Point p2, Rect r);
  117. void buffer_rectangles(vector<Rect> &rectangles);
  118. void reset(Rect &frog, vector<Rect> &trucks, vector<Rect> &cars,
  119.            vector<Rect> &logs, vector<Rect> &turtles);
  120.  
  121. int instinct_main()
  122. {
  123.    win.coord(0, -5, 100, 100);
  124.    win.play_music("omen.mp3", 1);
  125.  
  126.    Message msg_num_lives = Message(Point(25, -3),
  127.                                    LIVES, BLACK);
  128.  
  129.    Rect background = Rect(Point(0, 0),
  130.                           win.get_coord_width(), win.get_coord_height(),
  131.                           BLACK, true);
  132.    Rect river = Rect(Point(0, TURTLE_LANE1),
  133.                           win.get_coord_width(), FROG_SIZE * 6,
  134.                           BLUE, true);
  135.  
  136.    Rect frog;
  137.  
  138.    vector<Rect> trucks(4);
  139.    vector<Rect> cars(9);
  140.    vector<Rect> logs(6);
  141.    vector<Rect> turtles(9);
  142.    vector<Rect> pads(4);
  143.  
  144.    reset(frog, trucks, cars, logs, turtles);
  145.    init_pads(pads);
  146.  
  147.    Timer frog_tmr;
  148.    frog_tmr.start();
  149.    frog_tmr.add_time(FROG_WAIT);
  150.    Timer frame_tmr;
  151.    frame_tmr.start();
  152.  
  153.    win << background << river
  154.        << pads[0] << pads[1] << pads[2] << pads[3];
  155.    buffer_rectangles(trucks);
  156.    buffer_rectangles(cars);
  157.    buffer_rectangles(logs);
  158.    buffer_rectangles(turtles);
  159.    win << MSG_LIVES_LEFT << msg_num_lives << frog;
  160.  
  161.    int num_lives = LIVES;
  162.    bool frog_on_pad = false;
  163.    bool reset_objects = false;
  164.  
  165.    while (num_lives > 0 && !frog_on_pad)
  166.    {
  167.       if (reset_objects)
  168.       {
  169.         reset(frog, trucks, cars, logs, turtles);
  170.         frog_tmr.reset();
  171.     reset_objects = false;
  172.       }
  173.  
  174.       win.clear_buffer();
  175.  
  176.       move_frog(frog, frog_tmr);
  177.       move_trucks(trucks);
  178.       move_cars(cars);
  179.       move_logs(logs);
  180.       move_turtles(turtles);
  181.  
  182.       //each frame occurs no faster than FRAME_WAIT milliseconds
  183.       wait_for(FRAME_WAIT - frame_tmr.get_time());
  184.       frame_tmr.reset();
  185.  
  186.       win << background << river << pads[0] << pads[1];
  187.       buffer_rectangles(trucks);
  188.       buffer_rectangles(cars);
  189.       buffer_rectangles(logs);
  190.       buffer_rectangles(turtles);
  191.       win << MSG_LIVES_LEFT << msg_num_lives << frog;
  192.       win.output_buffer();
  193.  
  194.       Point  p_frog = frog.get_lower_left();
  195.       double x_frog = p_frog.get_x();
  196.       double y_frog = p_frog.get_y();
  197.  
  198.       if (y_frog >= TURTLE_LANE1 &&
  199.           (x_frog + FROG_SIZE <= 0 || x_frog >= win.get_coord_width()))
  200.       {
  201.     reset_objects = true;
  202.         msg_num_lives.set_text(--num_lives);
  203.       }
  204.       else if (collision(frog, logs))
  205.       {
  206.         if (y_frog == LOG_LANE1)
  207.           frog.move(-LOG_LANE1_SPEED, 0);
  208.         else if (y_frog == LOG_LANE2)
  209.           frog.move(-LOG_LANE2_SPEED, 0);
  210.         else if (y_frog == LOG_LANE3)
  211.           frog.move(-LOG_LANE3_SPEED, 0);
  212.       }
  213.       else if (collision(frog, turtles))
  214.       {
  215.         if (y_frog == TURTLE_LANE1)
  216.           frog.move(TURTLE_LANE1_SPEED, 0);
  217.         else if (y_frog == TURTLE_LANE2)
  218.           frog.move(TURTLE_LANE2_SPEED, 0);
  219.       }
  220.       else if (collision(frog, pads))
  221.       {
  222.         frog_on_pad = true;
  223.       }
  224.       else if (collision(frog, trucks) ||
  225.                collision(frog, cars)   ||
  226.            y_frog >= TURTLE_LANE1)
  227.       {
  228.         reset_objects = true;
  229.         msg_num_lives.set_text(--num_lives);
  230.       }
  231.    }
  232.  
  233.    win.clear_buffer();
  234.     output_splat( frog.get_lower_left() );
  235.    win << background << river << pads[0] << pads[1];
  236.    buffer_rectangles(trucks);
  237.    buffer_rectangles(cars);
  238.    buffer_rectangles(logs);
  239.    buffer_rectangles(turtles);
  240.    win << MSG_LIVES_LEFT << msg_num_lives << frog;
  241.  
  242.    if (frog_on_pad)
  243.      output_result(frog.get_lower_left(), "You Win!");
  244.    else
  245.      output_result(frog.get_lower_left(), "You Lose");
  246.  
  247.    win.output_buffer();
  248.  
  249.    return 0;
  250. }
  251.  
  252. void output_splat( Point frog )
  253. {
  254.     // x&y values of frog
  255.     double x_frog = frog.get_x();
  256.     double y_frog = frog.get_y();
  257.  
  258.     // x&y value and SPLAT message
  259.     double x_splat = x_frog - 2;
  260.     double y_splat = y_frog - 2;
  261.     Point psplat = Point(x_splat, y_splat);
  262.     Message splat = Message(psplat, "SPLAT", RED);
  263.     win << splat;
  264. }
  265.  
  266. void buffer_rectangles(vector<Rect> &rectangles)
  267. {
  268.   for (int i = 0; i < rectangles.size(); i++)
  269.     win << rectangles[i];
  270. }
  271.  
  272. void output_result(Point frog, string text)
  273. {
  274.   double frog_x = frog.get_x();
  275.   double frog_y = frog.get_y();
  276.  
  277.   //Point pos_frog_msg = Point(frog_x, frog_y);
  278.   Point pos_frog_msg = Point(frog_x - XPOS_OFFSET_FROG_MSG,
  279.                              frog_y - YPOS_OFFSET_FROG_MSG);
  280.  
  281.   Message msg = Message(pos_frog_msg, text, WHITE);
  282.  
  283.   win << msg;
  284. }
  285.  
  286. //frog can't move faster than once per FROG_WAIT milliseconds
  287. void move_frog( Rect &frog, Timer &frog_tmr )
  288. {
  289.   if (frog_tmr.get_time() >= FROG_WAIT)
  290.   {
  291.     if (win.is_key_down("up"))
  292.     {
  293.       frog.move(0, YMOVE);
  294.       frog_tmr.reset();
  295.     }
  296.     else if (win.is_key_down("down"))
  297.     {
  298.       frog.move(0, -YMOVE);
  299.       frog_tmr.reset();
  300.     }
  301.     else if (win.is_key_down("right"))
  302.     {
  303.       frog.move(XMOVE, 0);
  304.       frog_tmr.reset();
  305.     }
  306.     else if (win.is_key_down("left"))
  307.     {
  308.       frog.move(-XMOVE, 0);
  309.       frog_tmr.reset();
  310.     }
  311.   }
  312. }
  313.  
  314. void move_trucks(vector<Rect> &trucks)
  315. {
  316.   for (int i = 0; i < trucks.size(); i++)
  317.   {
  318.     Point  p = trucks[i].get_lower_left();
  319.     double x = p.get_x();
  320.     double y = p.get_y();
  321.  
  322.     if (x + trucks[i].get_width() <= 0)
  323.       trucks[i].move(win.get_coord_width() + trucks[i].get_width(), 0);
  324.  
  325.     if (i >= 2)
  326.       trucks[i].move(-TRUCK_LANE2_SPEED, 0);
  327.     else
  328.       trucks[i].move(-TRUCK_LANE1_SPEED, 0);
  329.   }
  330. }
  331.  
  332. void move_cars(vector<Rect> &cars)
  333. {
  334.   for (int i = 0; i < cars.size(); i++)
  335.   {
  336.     Point  p = cars[i].get_lower_left();
  337.     double x = p.get_x();
  338.     double y = p.get_y();
  339.  
  340.     if (x >= win.get_coord_width())
  341.       cars[i].move(-win.get_coord_width() - cars[i].get_width(), 0);
  342.  
  343.     if (i >= 6)
  344.       cars[i].move(CAR_LANE3_SPEED, 0);
  345.     else if (i >= 3)
  346.       cars[i].move(CAR_LANE2_SPEED, 0);
  347.     else
  348.       cars[i].move(CAR_LANE1_SPEED, 0);
  349.   }
  350. }
  351.  
  352. void move_logs(vector<Rect> &logs)
  353. {
  354.   for (int i = 0; i < logs.size(); i++)
  355.   {
  356.     Point  p = logs[i].get_lower_left();
  357.     double x = p.get_x();
  358.     double y = p.get_y();
  359.  
  360.     if (x + logs[i].get_width() <= 0)
  361.       logs[i].move(win.get_coord_width() + logs[i].get_width(), 0);
  362.  
  363.     if (i >= 4)
  364.       logs[i].move(-LOG_LANE3_SPEED, 0);
  365.     else if (i >= 2)
  366.       logs[i].move(-LOG_LANE2_SPEED, 0);
  367.     else
  368.       logs[i].move(-LOG_LANE1_SPEED, 0);
  369.   }
  370. }
  371.  
  372. void move_turtles(vector<Rect> &turtles)
  373. {
  374.   for (int i = 0; i < turtles.size(); i++)
  375.   {
  376.     Point  p = turtles[i].get_lower_left();
  377.     double x = p.get_x();
  378.     double y = p.get_y();
  379.  
  380.     if (x >= win.get_coord_width())
  381.       turtles[i].move(-win.get_coord_width() - turtles[i].get_width(), 0);
  382.  
  383.     if(i > 5)
  384.     {
  385.         turtles[i].move(TURTLE_LANE3_SPEED, 0);
  386.     }
  387.     else if(i > 2 && i < 6)
  388.     {
  389.         turtles[i].move(TURTLE_LANE2_SPEED, 0);
  390.     }
  391.     else
  392.       turtles[i].move(TURTLE_LANE1_SPEED, 0);
  393.   }
  394. }
  395.  
  396. // returns true if the point is in rectangle r
  397. bool inside( Point p, Rect r )
  398. {
  399.   Point r_lower_left = r.get_lower_left();
  400.   double r_lower_x = r_lower_left.get_x();
  401.   double r_lower_y = r_lower_left.get_y();
  402.   double width = r.get_width();
  403.   double height = r.get_height();
  404.  
  405.   double p_x = p.get_x();
  406.   double p_y = p.get_y();
  407.  
  408.   if (p_x > r_lower_x && p_x < (r_lower_x + width))
  409.     if (p_y > r_lower_y && p_y < (r_lower_y + height))
  410.       return true;
  411.  
  412.   return false;
  413. }
  414.  
  415. // function that returns true when a corner of r1 is in r2
  416. // or when two borders of r1 is overlapped with r2
  417. bool collision(Rect r1, vector<Rect> &rectangles)
  418. {
  419.   Point  p_r1_lower_left = r1.get_lower_left();
  420.   double p_r1_lower_x    = p_r1_lower_left.get_x();
  421.   double p_r1_lower_y    = p_r1_lower_left.get_y();
  422.   double r1_width        = r1.get_width();
  423.   double r1_height       = r1.get_height();
  424.  
  425.   Point p_r1_lower_right = Point(p_r1_lower_x + r1_width,
  426.                                  p_r1_lower_y);
  427.   Point p_r1_upper_left  = Point(p_r1_lower_x,
  428.                                  p_r1_lower_y + r1_height);
  429.   Point p_r1_upper_right = Point(p_r1_lower_x + r1_width,
  430.                                  p_r1_lower_y + r1_height);
  431.  
  432.   for (int i = 0; i < rectangles.size(); i++)
  433.   {
  434.     Rect r2 = rectangles[i];
  435.  
  436.     bool corner_inside = inside(p_r1_lower_left,  r2) ||
  437.                          inside(p_r1_upper_left,  r2) ||
  438.                          inside(p_r1_lower_right, r2) ||
  439.                          inside(p_r1_upper_right, r2);
  440.  
  441.     bool border_overlap =
  442.                is_border_overlap(p_r1_lower_left,  p_r1_upper_left,  r2) ||
  443.                is_border_overlap(p_r1_lower_right, p_r1_upper_right, r2) ||
  444.                is_border_overlap(p_r1_upper_left,  p_r1_upper_right, r2) ||
  445.                is_border_overlap(p_r1_lower_left,  p_r1_lower_right, r2);
  446.  
  447.     if (corner_inside || border_overlap)
  448.       return true;
  449.   }
  450.  
  451.   return false;
  452. }
  453.  
  454. // function that returns true when two borders are overlapped
  455. bool is_border_overlap(Point p1, Point p2, Rect r)
  456. {
  457.   Point r_lower_left = r.get_lower_left();
  458.   double r_lower_x   = r_lower_left.get_x();
  459.   double r_lower_y   = r_lower_left.get_y();
  460.   double width = r.get_width();
  461.   double height = r.get_height();
  462.  
  463.   double p1_x = p1.get_x();
  464.   double p1_y = p1.get_y();
  465.  
  466.   double p2_x = p2.get_x();
  467.   double p2_y = p2.get_y();
  468.  
  469.   bool p1_on_btm_border  = false;
  470.   bool p2_on_top_border  = false;
  471.   bool p1_on_left_border = false;
  472.   bool p2_on_rght_border = false;
  473.  
  474.   if (p1_x > r_lower_x && p1_x < r_lower_x + width)
  475.     if (p1_y == r_lower_y)
  476.       p1_on_btm_border = true;
  477.  
  478.   if (p2_x > r_lower_x && p2_x < r_lower_x + width)
  479.     if (p2_y == r_lower_y + height)
  480.       p2_on_top_border = true;
  481.  
  482.   if (p1_y > r_lower_y && p1_y < r_lower_y + height)
  483.     if (p1_x == r_lower_x)
  484.       p1_on_left_border = true;
  485.  
  486.   if (p2_y > r_lower_y && p2_y < r_lower_y + height)
  487.     if (p2_x == r_lower_x + width)
  488.       p2_on_rght_border = true;
  489.  
  490.   return (p1_on_btm_border  && p2_on_top_border) ||
  491.          (p1_on_left_border && p2_on_rght_border);
  492. }
  493.  
  494. Rect create_truck(double x, double y)
  495. {
  496.   return Rect(Point(x, y), TRUCK_W, TRUCK_H, PURPLE, true);
  497. }
  498.  
  499. Rect create_car(double x, double y)
  500. {
  501.   return Rect(Point(x, y), CAR_W, CAR_H, YELLOW, true);
  502. }
  503.  
  504. Rect create_log(double x, double y)
  505. {
  506.   return Rect(Point(x, y), LOG_W, LOG_H, BROWN, true);
  507. }
  508.  
  509. Rect create_turtle(double x, double y)
  510. {
  511.   return Rect(Point(x, y), TURTLE_W, TURTLE_H, DARK_GREEN, true);
  512. }
  513.  
  514. void init_frog(Rect &frog)
  515. {
  516.   frog = Rect(FROG_START, FROG_SIZE, FROG_SIZE * .99, GREEN, true);
  517. }
  518.  
  519. void init_trucks(vector<Rect> &trucks)
  520. {
  521.   trucks[0] = create_truck(TRUCK_LANE1_START, TRUCK_LANE1);
  522.   trucks[1] = create_truck(TRUCK_LANE1_START + TRUCK_GAP, TRUCK_LANE1);
  523.   trucks[2] = create_truck(TRUCK_LANE2_START, TRUCK_LANE2);
  524.   trucks[3] = create_truck(TRUCK_LANE2_START + TRUCK_GAP, TRUCK_LANE2);
  525. }
  526.  
  527. void init_cars(vector<Rect> &cars)
  528. {
  529.   cars[0] = create_car(CAR_LANE1_START, CAR_LANE1);
  530.   cars[1] = create_car(CAR_LANE1_START + CAR_GAP, CAR_LANE1);
  531.   cars[2] = create_car(CAR_LANE1_START + CAR_GAP * 2, CAR_LANE1);
  532.   cars[3] = create_car(CAR_LANE2_START, CAR_LANE2);
  533.   cars[4] = create_car(CAR_LANE2_START + CAR_GAP, CAR_LANE2);
  534.   cars[5] = create_car(CAR_LANE2_START + CAR_GAP * 2, CAR_LANE2);
  535.   cars[6] = create_car(CAR_LANE3_START, CAR_LANE3);
  536.   cars[7] = create_car(CAR_LANE3_START + CAR_GAP, CAR_LANE3);
  537.   cars[8] = create_car(CAR_LANE3_START + CAR_GAP * 2, CAR_LANE3);
  538. }
  539.  
  540. void init_logs(vector<Rect> &logs)
  541. {
  542.   logs[0] = create_log(LOG_LANE1_START, LOG_LANE1);
  543.   logs[1] = create_log(LOG_LANE1_START + LOG_GAP, LOG_LANE1);
  544.   logs[2] = create_log(LOG_LANE2_START, LOG_LANE2);
  545.   logs[3] = create_log(LOG_LANE2_START + LOG_GAP, LOG_LANE2);
  546.   logs[4] = create_log(LOG_LANE3_START + LOG_GAP, LOG_LANE3);
  547.   logs[5] = create_log(LOG_LANE3_START + LOG_GAP, LOG_LANE3);
  548. }
  549.  
  550. void init_turtles(vector<Rect> &turtles)
  551. {
  552.   turtles[0] = create_turtle(TURTLE_LANE1_START, TURTLE_LANE1);
  553.   turtles[1] = create_turtle(TURTLE_LANE1_START + TURTLE_GAP, TURTLE_LANE1);
  554.   turtles[2] = create_turtle(TURTLE_LANE1_START + (2*TURTLE_GAP), TURTLE_LANE1);
  555.   turtles[3] = create_turtle(TURTLE_LANE2_START, TURTLE_LANE2);
  556.   turtles[4] = create_turtle(TURTLE_LANE2_START + TURTLE_GAP, TURTLE_LANE2);
  557.   turtles[5] = create_turtle(TURTLE_LANE2_START + (2*TURTLE_GAP), TURTLE_LANE2);
  558.   turtles[6] = create_turtle(TURTLE_LANE3_START, TURTLE_LANE3);
  559.   turtles[7] = create_turtle(TURTLE_LANE3_START + TURTLE_GAP, TURTLE_LANE3);
  560.   turtles[8] = create_turtle(TURTLE_LANE3_START + (2*TURTLE_GAP), TURTLE_LANE3);
  561. }
  562.  
  563. void init_pads(vector<Rect> &pads)
  564. {
  565.   pads[0] = Rect(Point(PAD_XPOS1, PAD_YPOS), PAD_W, PAD_H, RED, true);
  566.   pads[1] = Rect(Point(PAD_XPOS2, PAD_YPOS), PAD_W, PAD_H, RED, true);
  567. }
  568.  
  569. void reset(Rect &frog, vector<Rect> &trucks, vector<Rect> &cars,
  570.            vector<Rect> &logs, vector<Rect> &turtles)
  571. {
  572.   init_frog(frog);
  573.   init_trucks(trucks);
  574.   init_cars(cars);
  575.   init_logs(logs);
  576.   init_turtles(turtles);
  577. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement