#include // for srand, EXIT_SUCCESS #include // for time #include // for size #include "terminal.h" #include "wolf.h" #include "rabbit.h" using namespace std; int main() { srand(static_cast(time(0))); const terminal term('.'); const unsigned xmax = term.xmax(); const unsigned ymax = term.ymax(); // Use whole number values for coordinates wolf w(term, 20, 10); // starting position of the wolf rabbit a[] { {term, 60, 10}, // rabbit 1 {term, 45, 5}, // rabbit 2 {term, 70, 15} // rabbit 3 }; const size_t n {size(a)}; // number of rabbits for (;; term.wait(250)) { if (!w.move()) { break; } for (size_t i = 0; i < n; ++i) { if (!a[i].move()) { term.put(0, 0, "You killed the rabbit!"); term.wait(3000); return EXIT_SUCCESS; } } } term.put(0, 0, "Game ended."); term.wait(3000); return EXIT_SUCCESS; }