#include "ccc_win.h" const double WIN_LEFT = 0; const double WIN_RIGHT = 100; const double WIN_TOP = 100; const double WIN_BOTTOM = 0; const double CENTER = 50; const double MOVEMENT = 5; void draw_box(Point ref_pt) { cwin << ref_pt; //left top line Point left_top_front = ref_pt; Point left_bottom_front = ref_pt; left_bottom_front.move(0,-20); cwin << Line(left_top_front, left_bottom_front); //left side of box Point left_top_back = left_top_front; Point left_bottom_back = left_bottom_front; left_top_back.move(-2,-4); left_bottom_back.move(-2,-4); cwin << Line(left_top_back, left_bottom_back) << Line(left_top_front, left_top_back) << Line(left_bottom_front, left_bottom_back); //right side of box Point right_top_front = left_top_front; Point right_bottom_front = left_bottom_front; Point right_bottom_back = left_bottom_back; right_top_front.move(40,0); right_bottom_front.move(40,0); right_bottom_back.move(40,0); //draws right side and connecting lines cwin << Line(right_top_front, right_bottom_front) << Line(right_bottom_front, right_bottom_back) << Line(left_top_front, right_top_front) << Line(left_bottom_front, right_bottom_front) << Line(left_bottom_back, right_bottom_back); //outputs name Point msg_pt = ref_pt; msg_pt.move(5,-9); cwin << Message(msg_pt, "GODIVA CHOCOLATES"); } int ccc_win_main() { //make own window cwin.coord(WIN_LEFT, WIN_TOP, WIN_RIGHT, WIN_BOTTOM); //start box in center of window Point box_pt(CENTER, CENTER); draw_box(box_pt); //let user move box to anywhere in window box_pt = cwin.get_mouse("Click where you want the box to start"); cwin.clear(); draw_box(box_pt); string direction; //move box left or right until ref pt hits window edge while (box_pt.get_x() > WIN_LEFT and box_pt.get_x() < WIN_RIGHT) { direction = cwin.get_string("Move (r)ight or (l)eft?"); //move right if (direction == "r") { cwin.clear(); box_pt.move(MOVEMENT,0); draw_box(box_pt); } //move left else if (direction == "l") { cwin.clear(); box_pt.move(-MOVEMENT,0); draw_box(box_pt); } }//end while cwin.clear(); cwin << Message(Point(CENTER - 20,CENTER + 5), "HAPPY VALENTINE'S DAY!!"); return 0; }