#include "library.h" const int fwidth = 800, fheight = 600, boundary = 25; struct targetless_actor { double x, y, speed; int colour; targetless_actor(double ox, double oy, double sp, int co) { x = ox; y = oy; speed = sp; colour = co; } void draw() { set_pen_width(7); set_pen_color(colour); draw_point(boundary + x, boundary + y); } }; struct actor: public targetless_actor { targetless_actor & target; actor(double ox, double oy, double sp, int co, targetless_actor & t): target(t), targetless_actor(ox, oy, sp, co) { } void draw() { targetless_actor::draw(); double dir = atan2(target.x - x, target.y - y); move_to(x, y); set_heading_radians(dir); set_pen_width(4); draw_distance(50); } }; void main() { make_window(fwidth + 2 * boundary, fheight + 2 * boundary); set_pen_width(3); move_to(boundary, boundary); draw_to(fwidth + boundary, boundary); draw_to(fwidth + boundary, fheight + boundary); draw_to(boundary, fheight + boundary); draw_to(boundary, boundary); targetless_actor tree(fwidth - 100, fheight / 2, 0, color::green); actor boy(75, fheight, 7, color::blue, tree); actor bull(50, 50, 6, color::red, boy); tree.draw(); boy.draw(); bull.draw(); }