#include //for the srand function and EXIT_SUCCESS #include //for the time function #include "terminal.h" #include "wolf.h" #include "rabbit.h" using namespace std; int main() { srand(static_cast(time(0))); //Seed random number generator. const terminal term {'.'}; const unsigned xmax {term.xmax()}; const unsigned ymax {term.ymax()}; wolf w {term, xmax * 1 / 3, ymax / 2}; rabbit a[] { {term, xmax * 2 / 3, ymax * 3 / 4}, {term, xmax * 2 / 3, ymax * 2 / 4}, {term, xmax * 2 / 3, ymax * 1 / 4} }; for (;; term.wait(250)) { //250 milliseconds is .25 seconds if (!w.move()) { break; } bool keep_game_going {true}; for (auto& r: a) { if (!r.move()) { keep_game_going = false; break; } } if (!keep_game_going) { break; } } term.put(0, 0, "You killed a rabbit!"); term.wait(3000); //Give the user three seconds to read the message. return EXIT_SUCCESS; //Destruct rabbits, wolf, & terminal,in that order. }