/********************************************************************** * * * Program: "Idyllic landscape animation" CSE 142 Spring 2000 * * Homework #4 * * Purpose: A game with user interaction and simple commands. * * The effective use of loops, event-driven programming, * * functions, random numbers, and more effective use of * * error handling. * * Author: Robert A. Currie, Section BG (Dunham) * * * **********************************************************************/ #include "gp142.h" #include #include #include /* * is included so the current time can be accessed * to initialize the random number generator. If you don't * use random numbers (and you don't have to) you can either * ignore this #include or delete it. */ /* Logical constants */ #define TRUE 1 #define FALSE 0 /* * For many of the GP142 functions, a line width of * zero means to fill the shape being drawn. The * constant FILL is used in function calls when a solid * shape is desired. */ #define FILL 0 /* Mouse click in some button */ #define BUTTON1_CLICK 1 #define BUTTON2_CLICK 2 #define BUTTON3_CLICK 3 #define BUTTON4_CLICK 4 #define BUTTON5_CLICK 5 #define BUTTON6_CLICK 6 #define BUTTON7_CLICK 7 #define BUTTON8_CLICK 8 #define BUTTON9_CLICK 9 #define BUTTON10_CLICK 10 #define BUTTON11_CLICK 11 /* cubes outline color */ #define OUTLINE_COLOR BLACK /* author's name icon color */ #define R_COLOR RED #define PI 3.14159265359 /* Mouse click elsewhere */ #define OTHER_CLICK 0 /* number of cubes */ /* NOTE: the actual number of cubes displayed is one less than the number shown here. This is to give a better visualized random affect. This can easily be changed so that the program draws the exact number of #defined cubes stated here. The first cube is the default cube which calculations are based on. To include the default cube in the displayed cubes, simply change the integer 'a' in the 'draw_cube' functions initial for loop from 'a=1' to 'a=0'. */ #define num_of_cubes 4 /***************************************************************************** FUNCTION PROTOTYPES *****************************************************************************/ /* Initialize random number generator. [Ignore or */ /* remove if your program doesn't use random numbers.] */ void initialize_random_numbers(); /* Program function prototypes */ /* draw cubes on screen */ void draw_cube(int rot_cube[], int *cube_color); /* draw author's name icon */ void draw_name(int letter_R[]); /* translate cubes around screen */ void move_cube(int def_trans_cube[],int mv_x,int mv_y); /* scale cubes on screen */ void scale_cube(int rot_cube[], int def_rot_cube[], double scl_x,double scl_y,double scl_z); /* default cube point values */ void initialize_cube(int rot_cube[], int def_rot_cube[], int letter_R[], int def_letter_R[]); /* change cubes color on screen */ void change_color(int *cube_color); /* total value cube translations */ void add_cube(int total_cube[], int rot_cube[], int def_trans_cube[], int counter); /* rotate cubes */ void cube_rotation(double C_sin[], double C_cos[], int ang_x, int ang_y, int ang_z, int rot_cube[], int def_rot_cube[], int counter); /* move extra cubes around screen */ void move_extra_cubes(int rot_cube[], int def_rot_cube[],int random_numbers[], int counter); /* draw buttons on screen */ void draw_buttons(int x_button_counter, int y_button_counter, int z_button_counter); /* draw toggled buttons */ void raised_x_button(); void raised_y_button(); void raised_z_button(); void pressed_x_button(); void pressed_y_button(); void pressed_z_button(); /* Return kind of mouse click (in a button, etc.) */ int classify_mouse_click(int mouse_x, int mouse_y, int def_trans_cube[]); /* Display error message if internal error is detected. */ void something_is_wrong (void); /***************************************************************************** MAIN *****************************************************************************/ /* * Main program contents: * - Major program variables that persist throughout execution * - Event loop that processes GP142 events until the user quits, * and updates variables and redraws the window as needed. */ int main(void) { /* Event handling and buttons: */ int quit; /* = "user has selected quit" */ int event; /* the most recent GP142 event */ char key_pressed; /* last keyboard character from key event */ int mouse_x, mouse_y; /* x and y coordinates of latest mouse event*/ int click_kind; /* kind of mouse click (button, etc.) */ /* arrays used throughout program for cube translations, etc... */ int rot_cube[num_of_cubes * 120]; int def_rot_cube[num_of_cubes * 120]; int def_trans_cube[num_of_cubes * 120]; int total_cube[num_of_cubes * 120]; /* author's name icon array's */ int letter_R[96]; int def_letter_R[96]; int final_name[96]; /* random number array used for randomizing cubes */ int random_numbers[num_of_cubes]; /* values used to calculate cube rotation */ double C_sin[360], C_cos[360]; /* default cube color */ int cube_color = LT_GRAY; /* default cube rotated angle */ int ang_x=0, ang_y=0, ang_z=0; /* default author's name icon rotated angles */ int nm_ang_x=0,nm_ang_y=0,nm_ang_z=0; /* translation counter defaults */ int mv_x=0,mv_y=0; double scl_x=1,scl_y=1, scl_z=1; int scl_counter_up = 0; int scl_counter_down = 0; double scl_up = 0; double scl_down = 0; /* general purpose integers for initial setup */ int a,b,c; /* cube randomization toggle */ int randomize = FALSE; /* counters for rotation buttons */ int x_button_counter = 0; int y_button_counter = 0; int z_button_counter = 0; /* Initialize random number generator */ initialize_random_numbers(); /* Initialize graphics package, clear the window, */ /* turn logging off, and start animation. */ GP142_open(); GP142_logging(LOG_OFF); GP142_clear(); GP142_animate(ANI_RUN); for(a=0; a<360; a++) { C_sin[a]= sin(a*PI/180); C_cos[a] = cos(a*PI/180); } for(b=0;b<(num_of_cubes * 120) ;b++) { def_trans_cube[b] = 0; } for(c=0;c<(num_of_cubes*2);c+=2) { random_numbers[c] = (rand()%100)+(rand()%100); random_numbers[c+1] = (rand()%100)+(rand()%100); } draw_buttons(x_button_counter, y_button_counter, z_button_counter); initialize_cube(rot_cube, def_rot_cube, letter_R, def_letter_R); move_extra_cubes(rot_cube, def_rot_cube,random_numbers,FALSE); /* * Main event loop: * ---- ----- ----- * Wait for the next user action, decode it, and call an * appropriate function to handle it. Repeat until the * user selects quit. */ quit = FALSE; while (!quit) { /* get next event */ event = GP142_await_event(&mouse_x, &mouse_y, &key_pressed); /* perform appropriate action depending on kind of event */ switch (event) { case GP142_QUIT: /* Quit selected */ quit = TRUE; break; case GP142_KBD: /* Key pressed. Not used now. If the program should */ /* react to keyboard events, insert something appropriate */ /* here. Note that scanf CANNOT be used with GP142. */ break; case GP142_MOUSE: /* Mouse click. Determine if in a menu button */ /* or elsewhere and process accordingly. */ click_kind = classify_mouse_click(mouse_x, mouse_y, def_trans_cube); switch(click_kind) { /* move cubes to the left */ case 1: GP142_clear(); mv_x -= 10; move_cube(def_trans_cube,mv_x,0); break; /* move cubes up */ case 2: GP142_clear(); mv_y += 10; move_cube(def_trans_cube,0,mv_y); break; /* move cubes to the right */ case 3: GP142_clear(); mv_x += 10; move_cube(def_trans_cube,mv_x,0); break; /* move cubes down */ case 4: GP142_clear(); mv_y -= 10; move_cube(def_trans_cube,0,mv_y); break; /* scale cubes up */ case 5: if(scl_counter_up < 10) { GP142_clear(); scl_counter_up++; scl_counter_down++; scl_x += .1; scl_y += .1; scl_z += .1; initialize_cube(rot_cube,def_rot_cube,letter_R,def_letter_R); scale_cube(rot_cube,def_rot_cube,scl_x,scl_y,scl_z); cube_rotation(C_sin, C_cos,ang_x, ang_y, ang_z, rot_cube, def_rot_cube,FALSE); move_extra_cubes(rot_cube, def_rot_cube,random_numbers,TRUE); add_cube(total_cube, rot_cube, def_trans_cube,FALSE); draw_cube(total_cube,&cube_color); draw_name(final_name); } break; /* scale cubes down */ case 6: if(scl_counter_down > -10) { GP142_clear(); scl_counter_down--; scl_counter_up--; scl_x -= .1; scl_y -= .1; scl_z -= .1; initialize_cube(rot_cube,def_rot_cube,letter_R,def_letter_R); scale_cube(rot_cube,def_rot_cube,scl_x,scl_y,scl_z); cube_rotation(C_sin, C_cos,ang_x, ang_y, ang_z, rot_cube, def_rot_cube,FALSE); move_extra_cubes(rot_cube, def_rot_cube,random_numbers,TRUE); add_cube(total_cube, rot_cube, def_trans_cube,FALSE); draw_cube(total_cube,&cube_color); draw_name(final_name); } break; /* change cubes color */ case 7: change_color(&cube_color); break; /* depress the 'x' rotation button */ case 8: x_button_counter++; break; /* depress the 'y' rotation button */ case 9: y_button_counter++; break; /* depress the 'z' rotation button */ case 10: z_button_counter++; break; /* randomize cubes locations */ case 11: randomize = 1; break; default: break; } draw_cube(total_cube,&cube_color); draw_name(final_name); break; case GP142_PERIODIC: /* Timer interval event. Update everything that needs the change */ /* as time advances. Animation should go here! */ GP142_clear(); /* if 'x' rotation button is pressed, rotate cubes around their x-axis */ if(x_button_counter%2 == TRUE) { ang_x++; if(ang_x == 360) ang_x = 0; } /* if 'y' rotation button is pressed, rotate cubes around their x-axis */ if(y_button_counter%2 == TRUE) { ang_y++; if(ang_y == 360) ang_y = 0; } /* if 'z' rotation button is pressed, rotate cubes around their x-axis */ if(z_button_counter%2 == TRUE) { ang_z++; if(ang_z == 360) ang_z = 0; } /* rotate 'R' in author's name */ nm_ang_x+=10; nm_ang_y+=10; /*nm_ang_z+=10;*/ if(nm_ang_x == 360) nm_ang_x = 0; if(nm_ang_y == 360) nm_ang_y = 0; /*if(nm_ang_z == 360) nm_ang_z = 0;*/ initialize_cube(rot_cube,def_rot_cube, letter_R,def_letter_R); scale_cube(rot_cube,def_rot_cube,scl_x,scl_y,scl_z); cube_rotation(C_sin, C_cos,ang_x, ang_y, ang_z, rot_cube, def_rot_cube, FALSE); cube_rotation(C_sin, C_cos,nm_ang_x, nm_ang_y, nm_ang_z, letter_R, def_letter_R, TRUE); move_extra_cubes(rot_cube, def_rot_cube,random_numbers,TRUE); add_cube(total_cube, rot_cube, def_trans_cube,FALSE); add_cube(final_name,letter_R,letter_R,TRUE); draw_cube(total_cube,&cube_color); draw_name(final_name); break; default: /* unknown event */ break; } /*end switch */ /* Redraw everything */ mv_x = 0; mv_y = 0; /* reset random cube location values if randomized button is pressed */ if(randomize == TRUE) { for(c=0;c<(num_of_cubes*2);c+=2) { random_numbers[c] = (rand()%100)+(rand()%100); random_numbers[c+1] = (rand()%100)+(rand()%100); } randomize = FALSE; move_extra_cubes(rot_cube, def_rot_cube,random_numbers,FALSE); } draw_buttons(x_button_counter, y_button_counter, z_button_counter); } /* end event loop */ /* Termination: shut down graphics window and exit */ GP142_close(); return 0; } /* end main */ /***************************************************************************** INITIALIZATION PROCEDURES *****************************************************************************/ /*draw cubes on screen */ void draw_cube(int cube[], int *cube_color) { int a,b; for(a=1;a -290) && (mouse_x < -270) && (mouse_y < 220) &&(mouse_y > 200)) return BUTTON1_CLICK; if ((mouse_x > -270) && (mouse_x < -250) && (mouse_y < 240) && (mouse_y > 220)) return BUTTON2_CLICK; if ((mouse_x > -250) && (mouse_x < -230) && (mouse_y < 220) && (mouse_y > 200)) return BUTTON3_CLICK; if ((mouse_x > -270) && (mouse_x < -250) && (mouse_y < 200) && (mouse_y > 180)) return BUTTON4_CLICK; if(((mouse_x > -275) && (mouse_x < -250) && (mouse_y < 150) && (mouse_y > 130)) || ((mouse_x > -265) && (mouse_x < -250) && (mouse_y < 140) && (mouse_y > 130))) return BUTTON5_CLICK; if(((mouse_x > -275) && (mouse_x < -250) && (mouse_y < 120) && (mouse_y > 95)) || ((mouse_x > -265) && (mouse_x < -250) && (mouse_y < 120) && (mouse_y > 95))) return BUTTON6_CLICK; if((mouse_x > 250) && (mouse_x < 270) && (mouse_y < 240) && (mouse_y > 220)) return BUTTON7_CLICK; if((mouse_x > 250) && (mouse_x < 270) && (mouse_y < 180) && (mouse_y > 160)) return BUTTON8_CLICK; if((mouse_x > 250) && (mouse_x < 270) && (mouse_y < 150) && (mouse_y > 130)) return BUTTON9_CLICK; if((mouse_x > 250) && (mouse_x < 270) && (mouse_y < 120) && (mouse_y > 100)) return BUTTON10_CLICK; if((mouse_x > -45) && (mouse_x < 45) && (mouse_y < 240) && (mouse_y > 220)) return BUTTON11_CLICK; else return OTHER_CLICK; } /* draw toggles for rotational buttons */ void raised_x_button() { /* raised 'x' button */ GP142_triangleXY(MED_GRAY, 250, 180, 254, 176, 254, 164 ,FILL); GP142_triangleXY(MED_GRAY, 254, 164, 250, 160, 250, 180 ,FILL); GP142_triangleXY(MED_GRAY, 250, 160, 254, 164, 270, 160 ,FILL); GP142_triangleXY(MED_GRAY, 270, 160, 266, 164, 254, 164 ,FILL); GP142_rectangleXY(LT_GRAY, 254, 176, 266, 164 ,FILL); GP142_triangleXY(LT_GRAY, 250, 180, 254, 176, 266, 176 ,FILL); GP142_triangleXY(LT_GRAY, 266, 176, 270, 180, 250, 180 ,FILL); GP142_triangleXY(LT_GRAY, 266, 176, 270, 180, 270, 160 ,FILL); GP142_triangleXY(LT_GRAY, 270, 160, 266, 164, 266, 176 ,FILL); GP142_rectangleXY(BLACK, 270, 180, 250, 160, 2); GP142_rectangleXY(BLACK, 266, 176, 254, 164, 1); GP142_lineXY(BLACK, 270, 180, 266, 176, 1); GP142_lineXY(BLACK, 250, 180, 254, 176, 1); GP142_lineXY(BLACK, 250, 160, 254, 164, 1); GP142_lineXY(BLACK, 270, 160, 266, 164, 1); } void pressed_x_button() { /* pressed 'x' button */ GP142_triangleXY(LT_GRAY, 250, 180, 254, 176, 254, 164 ,FILL); GP142_triangleXY(LT_GRAY, 254, 164, 250, 160, 250, 180 ,FILL); GP142_triangleXY(LT_GRAY, 250, 160, 254, 164, 270, 160 ,FILL); GP142_triangleXY(LT_GRAY, 270, 160, 266, 164, 254, 164 ,FILL); GP142_rectangleXY(MED_GRAY, 254, 176, 266, 164 ,FILL); GP142_triangleXY(MED_GRAY, 250, 180, 254, 176, 266, 176 ,FILL); GP142_triangleXY(MED_GRAY, 266, 176, 270, 180, 250, 180 ,FILL); GP142_triangleXY(MED_GRAY, 266, 176, 270, 180, 270, 160 ,FILL); GP142_triangleXY(MED_GRAY, 270, 160, 266, 164, 266, 176 ,FILL); GP142_rectangleXY(BLACK, 270, 180, 250, 160, 2); GP142_rectangleXY(BLACK, 266, 176, 254, 164, 1); GP142_lineXY(BLACK, 270, 180, 266, 176, 1); GP142_lineXY(BLACK, 250, 180, 254, 176, 1); GP142_lineXY(BLACK, 250, 160, 254, 164, 1); GP142_lineXY(BLACK, 270, 160, 266, 164, 1); GP142_triangleXY(BLUE,281,180,284,180,289,160,FILL); GP142_triangleXY(BLUE,281,180,286,160,289,160,FILL); GP142_triangleXY(BLUE,281,160,284,160,286,180,FILL); GP142_triangleXY(BLUE,284,160,286,180,289,180,FILL); GP142_lineXY(BLACK,281,180,284,180,1); GP142_lineXY(BLACK,284,180,285,174,1); GP142_lineXY(BLACK,285,174,286,180,1); GP142_lineXY(BLACK,286,180,289,180,1); GP142_lineXY(BLACK,289,180,287,170,1); GP142_lineXY(BLACK,287,170,289,160,1); GP142_lineXY(BLACK,289,160,286,160,1); GP142_lineXY(BLACK,286,160,285,166,1); GP142_lineXY(BLACK,285,166,284,160,1); GP142_lineXY(BLACK,284,160,281,160,1); GP142_lineXY(BLACK,281,160,283,170,1); GP142_lineXY(BLACK,283,170,281,180,1); } void raised_y_button() { /* raised 'y' button */ GP142_triangleXY(MED_GRAY, 250, 150, 254, 146, 254, 134 ,FILL); GP142_triangleXY(MED_GRAY, 254, 134, 250, 130, 250, 150 ,FILL); GP142_triangleXY(MED_GRAY, 250, 130, 254, 134, 270, 130 ,FILL); GP142_triangleXY(MED_GRAY, 270, 130, 266, 134, 254, 134 ,FILL); GP142_rectangleXY(LT_GRAY, 254, 146, 266, 134 ,FILL); GP142_triangleXY(LT_GRAY, 250, 150, 254, 146, 266, 146 ,FILL); GP142_triangleXY(LT_GRAY, 266, 146, 270, 150, 250, 150 ,FILL); GP142_triangleXY(LT_GRAY, 266, 146, 270, 150, 270, 130 ,FILL); GP142_triangleXY(LT_GRAY, 270, 130, 266, 134, 266, 146 ,FILL); GP142_rectangleXY(BLACK, 270, 150, 250, 130, 2); GP142_rectangleXY(BLACK, 266, 146, 254, 134, 1); GP142_lineXY(BLACK, 270, 150, 266, 146, 1); GP142_lineXY(BLACK, 250, 150, 254, 146, 1); GP142_lineXY(BLACK, 250, 130, 254, 134, 1); GP142_lineXY(BLACK, 270, 130, 266, 134, 1); } void pressed_y_button() { /* pressed 'y' button */ GP142_triangleXY(LT_GRAY, 250, 150, 254, 146, 254, 134 ,FILL); GP142_triangleXY(LT_GRAY, 254, 134, 250, 130, 250, 150 ,FILL); GP142_triangleXY(LT_GRAY, 250, 130, 254, 134, 270, 130 ,FILL); GP142_triangleXY(LT_GRAY, 270, 130, 266, 134, 254, 134 ,FILL); GP142_rectangleXY(MED_GRAY, 254, 146, 266, 134 ,FILL); GP142_triangleXY(MED_GRAY, 250, 150, 254, 146, 266, 146 ,FILL); GP142_triangleXY(MED_GRAY, 266, 146, 270, 150, 250, 150 ,FILL); GP142_triangleXY(MED_GRAY, 266, 146, 270, 150, 270, 130 ,FILL); GP142_triangleXY(MED_GRAY, 270, 130, 266, 134, 266, 146 ,FILL); GP142_rectangleXY(BLACK, 270, 150, 250, 130, 2); GP142_rectangleXY(BLACK, 266, 146, 254, 134, 1); GP142_lineXY(BLACK, 270, 150, 266, 146, 1); GP142_lineXY(BLACK, 250, 150, 254, 146, 1); GP142_lineXY(BLACK, 250, 130, 254, 134, 1); GP142_lineXY(BLACK, 270, 130, 266, 134, 1); GP142_triangleXY(GREEN,280,150,283,150,284,140,FILL); GP142_triangleXY(GREEN,284,140,283,150,285,144,FILL); GP142_triangleXY(GREEN,285,144,284,140,284,130,FILL); GP142_triangleXY(GREEN,284,130,286,130,285,144,FILL); GP142_triangleXY(GREEN,285,144,286,130,286,140,FILL); GP142_triangleXY(GREEN,286,140,287,150,285,144,FILL); GP142_triangleXY(GREEN,287,150,290,150,286,140,FILL); GP142_lineXY(BLACK,280,150,283,150,1); GP142_lineXY(BLACK,283,150,285,144,1); GP142_lineXY(BLACK,285,144,287,150,1); GP142_lineXY(BLACK,287,150,290,150,1); GP142_lineXY(BLACK,290,150,286,140,1); GP142_lineXY(BLACK,286,140,286,130,1); GP142_lineXY(BLACK,286,130,284,130,1); GP142_lineXY(BLACK,284,130,284,140,1); GP142_lineXY(BLACK,284,140,280,150,1); } void raised_z_button() { /* raised 'z' button */ GP142_triangleXY(MED_GRAY, 250, 120, 254, 116, 254, 104 ,FILL); GP142_triangleXY(MED_GRAY, 254, 104, 250, 100, 250, 120 ,FILL); GP142_triangleXY(MED_GRAY, 250, 100, 254, 104, 270, 100 ,FILL); GP142_triangleXY(MED_GRAY, 270, 100, 266, 104, 254, 104 ,FILL); GP142_rectangleXY(LT_GRAY, 254, 116, 266, 104 ,FILL); GP142_triangleXY(LT_GRAY, 250, 120, 254, 116, 266, 116 ,FILL); GP142_triangleXY(LT_GRAY, 266, 116, 270, 120, 250, 120 ,FILL); GP142_triangleXY(LT_GRAY, 266, 116, 270, 120, 270, 100 ,FILL); GP142_triangleXY(LT_GRAY, 270, 100, 266, 104, 266, 116 ,FILL); GP142_rectangleXY(BLACK, 270, 120, 250, 100, 2); GP142_rectangleXY(BLACK, 266, 116, 254, 104, 1); GP142_lineXY(BLACK, 270, 120, 266, 116, 1); GP142_lineXY(BLACK, 250, 120, 254, 116, 1); GP142_lineXY(BLACK, 250, 100, 254, 104, 1); GP142_lineXY(BLACK, 270, 100, 266, 104, 1); } void pressed_z_button() { /* pressed 'z' button */ GP142_triangleXY(LT_GRAY, 250, 120, 254, 116, 254, 104 ,FILL); GP142_triangleXY(LT_GRAY, 254, 104, 250, 100, 250, 120 ,FILL); GP142_triangleXY(LT_GRAY, 250, 100, 254, 104, 270, 100 ,FILL); GP142_triangleXY(LT_GRAY, 270, 100, 266, 104, 254, 104 ,FILL); GP142_rectangleXY(MED_GRAY, 254, 116, 266, 104 ,FILL); GP142_triangleXY(MED_GRAY, 250, 120, 254, 116, 266, 116 ,FILL); GP142_triangleXY(MED_GRAY, 266, 116, 270, 120, 250, 120 ,FILL); GP142_triangleXY(MED_GRAY, 266, 116, 270, 120, 270, 100 ,FILL); GP142_triangleXY(MED_GRAY, 270, 100, 266, 104, 266, 116 ,FILL); GP142_rectangleXY(BLACK, 270, 120, 250, 100, 2); GP142_rectangleXY(BLACK, 266, 116, 254, 104, 1); GP142_lineXY(BLACK, 270, 120, 266, 116, 1); GP142_lineXY(BLACK, 250, 120, 254, 116, 1); GP142_lineXY(BLACK, 250, 100, 254, 104, 1); GP142_lineXY(BLACK, 270, 100, 266, 104, 1); GP142_triangleXY(RED,281,120,281,118,289,120,FILL); GP142_triangleXY(RED,281,118,289,120,289,118,FILL); GP142_triangleXY(RED,286,118,289,118,281,102,FILL); GP142_triangleXY(RED,281,102,285,102,289,118,FILL); GP142_triangleXY(RED,281,102,281,100,289,102,FILL); GP142_triangleXY(RED,281,100,289,100,289,102,FILL); GP142_lineXY(BLACK,281,120,289,120,1); GP142_lineXY(BLACK,289,120,289,118,1); GP142_lineXY(BLACK,289,118,284,102,1); GP142_lineXY(BLACK,284,102,289, 102,1); GP142_lineXY(BLACK,289,102,289,100,1); GP142_lineXY(BLACK,289,100,281,100,1); GP142_lineXY(BLACK,281,100,281,102,1); GP142_lineXY(BLACK,281,102,286,118,1); GP142_lineXY(BLACK,286,118,281,118,1); GP142_lineXY(BLACK,281,118,281,120,1); } /***************************************************************************** OTHER *****************************************************************************/ /* Initialize random number generator */ /* [Ignore or delete if your program */ /* doesn't user random numbers.] */ void initialize_random_numbers() { time_t t; /* current time */ srand (time(&t)); } /* Display error message if internal error is detected. */ void something_is_wrong (void) { GP142_printfXY (RED, 0, 0, 16, "Program error!"); }