#include
// the screen is 640 * 480 # define SCR_MAX_X 639 # define SCR_MAX_Y 479
// define color -1 # define black 0 # define blue 1 # define green 2 # define cyan 3 # define red 4 # define magenta 5 # define brown 6 # Define LGRAY 7 # define Dgray 8 # define lblue 9 # Define lgreen 10 # define lcyan 11 # define Lred 12 # define LMAGENTA 13 # Define Yellow 14 # define White 15
#define ESC 0x011B
// public declareenum bool {true = 1, false = 0}; // boolint tag [100] = {0}; int xxx = 0, yyy = 0; int POS [11] [11] = {0};
// DECLARE CLASSCLASS CRECT // This Class Is Design for Draw A Rectangle with shadow {public: int X0, y0, x1, y1; // (x0, y0), (x1, y1) CRECT (int xx0, int yy0, INT XX1, INT YY1) // GET X0, Y0, X1, Y1 = YY0; X1 = XX1; Y1 = YY1;} // Draw A Rectangle with Shadow Void Draw (int color, int linecolor = White, Bool Shadow = False, INT Deep = 3);
// Function About Class CRECT / * ---------------------------- Name: CRECT :: Draw (int Color, Int LineColor, BOOL shadow, int deep) Function: Draw a rectangleInput: int color: fillcolor int lineColor: linecolor BOOL shadow: TRUE (1): with shadow FALSE (0): noshadow int deep: the deep of the shadowOutput: void ---- --------------------------- * / void CRECT :: Draw (int color, int linecolor, bool shadow, int desip) {setFillStyle Solid_Fill, Color; Bar (X0, Y0, X1, Y1);
IF (Shadow) {// Draw Right Shadow INT POLY [8]; POLY [0] = x1; // 1st Vertex Poly [1] = Y0; POLY [2] = x1 deep; // 2nd Vertex Poly [3 ] = Y0 Deep; Poly [4] = x1 deep; // 3rd Vertex Poly [5] = Y1 Deep; poly [6] = x1; // 4th Vertex Poly [7] = Y1; setColor (DGRAY) SetFillStyle (Solid_Fill, Dgray); FillPoly (4, POLY); // Fill the Poly // Draw The Bottom Shadow Poly [0] = x1 Deep; // 1st Vertex Poly [1] = Y1 Deep; POLY [ 2] = X0 Deep; // 2nd Vertex Poly [3] = Y1 Deep; Poly [4] = X0; // 3rd Vertex Poly [5] = Y1; POLY [6] = x1; // 4th Vertex POLY [7] = Y1; setColor (Black); setfillstyle (Solid_Fill, Black); FillPoly (4, poly); // Fill the poly}
IF (LineColor! = -1) // - 1: Nocolor {setColor (LineColor); Rectangle (X0, Y0, X1, Y1);
}
/ * ----------------------------- Name: showwindlg (char TTL [], char msg1 [], char msg2 []) Function: Show a Windows Dialog and Wait for a Key ('Y', 'N') INPUT: CHAR TTL []: Title Char MSG1 []: The first line char msg2 []: the second lineoutput: 1: Accept A Key 'Y' 0: ACCEPY A Key 'N' ------------------------------- * / int showwindlg (char TTL [ ], char msg1 [], char msg2 []) {CRect rect (165,180,475,280); CRect rectyes (210,250,310,270); CRect rectno (325,250,425,270); CRect title (165,180,475,195); void * oldImage; // Declare a image point unsigned int size ; // Recort the image size int key = 0; // reset the key
// Calculate the size of the image size = imageSize (Rect.x0, Rect.y0, Rect.x1 10, Rect.y1 10); // allocate memory to hold the image = malloc (size); // Grab The Image GetImage (Rect.x0, Rect.y0, Rect.x1 10, Rect.y1 10, OldImage); // Draw The Dialog Rect.draw (LBLUE, White, True, 5); Title.draw White, white); Rectyes.draw (White, Black, True, 3); RectNo.draw (White, Black, True, 3); Outtextxy (Rectyes.x0 10, Rectyes.y0 5, "Yes"); Outtextxy (RectNo.x0 10, RectNo.y0 5, "NO");
// output the text setColor (Black); setTextJustify (Left_text, Top_text); Outtextxy (Title.x0 10, Title.y0 5, TTL); Outtextxy (Rect.x0 12, Rect.y0 30, MSG1) Outtextxy (Rect.x0 12, Rect.y0 50, MSG2); setColor (White); Outtextxy (Rect.x0 11, Rect.y0 29, MSG1); OutTextxy (Rect.x0 11, RECT. Y0 49, MSG2); Do // DO Until Press y or n or n {key = bioskey (0); if (key == 5497 || Key == 5465) // y or y {// close The Dialog Putimage (Rect.x0, Rect.y0, OldImage, Copy_put); // Clean Up Free (OldImage); RETURN 0;} else} else} Else IF (key == 12654 || key == 12622) // n or n { // Close The Dialog Putimage (Rect.x0, Rect.y0, OldImage, Copy_put); // Clean Up Free (OldImage); Return 1;}} While (1);
/ * ---------------------------- Name: Waitdlg (int NDELAY, CHAR MSG []) Function: Show A Windows Dialoginput: INT NDELAY: DELAY: DELAY SOME TIMES CHAR MSG []: MessageOutput: Void ------------------------------- * / void Waitdlg ( Int ndelay, char msg []) {CRECT Rect (200, 210, 440, 270); CRECT TITLE (200, 210, 440, 225); Void * OldImage; // Declare a Image Point Unsigned Int size; // Recort The Image Size
// Calculate the size of the image size = imageSize (Rect.x0, Rect.y0, Rect.x1 10, Rect.y1 10); // allocate memory to hold the image = malloc (size); // Grab The Image GetImage (Rect.x0, Rect.y0, Rect.x1 10, Rect.y1 10, OldImage); // Draw the Wait Dialog Rect.draw (LBlue, White, True, 5); Title.draw (White, White); SetColor (Black); Outtextxy (Title.x0 10, Title.y0 5, "LEFT_TEXT, TOP_TEXT); OUTTEXTXY (Rect.x0 15 1, Rect.y0 30 2, MSG); // Draw the Shadow SetColor (White); OUTTEXTXY (Rect.x0 15, Rect.y0 30, MSG); // Draw The MSG Delay (nDElay ); // delay some time
// hide the dialog putimage (Rect.x0, Rect.y0, OldImage, Copy_put); // Clean Up Free (OldImage);
/ * ---------------------------- Name: Showwelcome (int NDELAY, INT LN, CHAR MSG [] [50]) Function : Show a windows about my97input: voidoutput: void ------------------------------- * / void Showwelcome (char strtitle [] = "" "= {" College: College of Science "," & Technology "," Myclass: Computer 1, Grade 3 "," Name1: li Bingbing "," Name2: Huang Zhongzhou " , "Name3: Ye Junqiang", "Company: ReachStar"}; int ln = 7; CRect rect (200,150,440,315); CRect middle (200,165,440,300); void * oldImage; // Declare a image point unsigned int size; // Recort the Image size
// Calculate the size of the image size = imageSize (Rect.x0, Rect.y0, Rect.x1 10, Rect.y1 10); // allocate memory to hold the image = malloc (size); // Grab The Image GetImage (Rect.x0, Rect.y0, Rect.x1 10, Rect.y1 10, OldImage);
// Draw the Dialog Rect.draw (Green, Black, True, 5); // Draw the Green Rectangle Middle.draw (LBLUE, Black); // Draw The Lblue Rectangle SetColor (White); Outtextxy (Rect.x0 10, Rect.y0 5, "About the program"); setTextJustify (left_text, top_text); ln-; for (; ln> = 0; ln -) {setColor (blue); OutTextxy (Rect.x0 15 2, Rect.y0 25 1 ln * 18, MSG [ln]); // Draw the shadow setColor (White); Outtextxy (Rect.x0 15, Rect.y0 25 ln * 18, MSG [ln]); // Draw the msg} // Draw the title f (strtitle [0]! = '/ 0') // input a title {create title (200, 80, 440, 120); Title.draw (LBLUE, White, True, 5); // Draw The Green Rectangle setColor (YELLOW); Outtextxy (Title.x0 15, Title.y0 15, strtitle); // Draw the title} while (! Kbhit ()) {setColor (Green); OUTTEXTXY (Rect.x0 15, Middle.y1 5, "Press Any Key To Continue!"); DELAY (500); setColor (White); Outtextxy (Rect.x0 15, Middle.y1 5, "Press any key to pay!"); Delay (500);}; ln = bioskey (0); // recieve the Waste Key // hide the dialog putimage (Rect.x0, Rect.y0, OldImage, Copy_put); // Clean Up Free (OldImage);
/ * ---------------------------- Name: ShowMessage (int NDELAY, INT LN, CHAR MSG [] [50]) Function : Show a Windows About My97Input: Voidoutput: Void ------------------------------- * / char showmessage (char msg [30 ], int x1 = 200, int x2 = 440, int y2 = 215) {int key; CRECT RECT (x1, y1, x2, y2); CRECT MIDDLE (X1, Y1 15, X2, Y2 -15); void * OldImage; // declare a image point point unsigned int size; // Recort the Image Size
// Calculate the size of the image size = imageSize (Rect.x0, Rect.y0, Rect.x1 10, Rect.y1 10); // allocate memory to hold the image = malloc (size); // Grab The Image GetImage (Rect.x0, Rect.y0, Rect.x1 10, Rect.y1 10, OldImage); // Draw The Dialog Rect.draw (Green, Black, True, 5); // Draw THE Green Rectangle Middle.draw (LBLUE, Black); // Draw The Lblue Rectangle SetColor (White); OUTTEXTXY (Rect.x0 10, Rect.y0 5, "About My97); setTextJustify (left_text, top_text);
SetColor (Blue); Outtextxy (Rect.x0 15 2, Rect.y0 25 1, MSG); // Draw the shadow setcolor (white); Outtextxy (Rect.x0 15, Rect.y0 25, MSG); // Draw the MSG
While (1) {key = bioskey (0); // recieve the key if ((char) key> = '0' && (char) key <= '9') {// hide the dialog putimage (Rect.x0 , Rect.y0, OldImage, Copy_put); // Clean Up Free (OldImage); Return (Char) Key;}}}
/ * ---------------------------- Name: DrawBackground () Function: DrawBackgroundInput: voidoutput: void ------- ------------------------ * / void DrawBackground () {// Draw the Background setFillStyle (LTBKSLASH_FILL, GREEN); bar (0, 0, SCR_MAX_X , SCR_MAX_Y);
// Draw the top setFillStyle (Solid_Fill, White); BAR (0, 0, SCR_MAX_X, 15); setColor (Black); Outtextxy (5, 4, "build: 2004-12-11 20:00:00 Powered by Computer 1, grade 3 Copyright: Reachstar "); LINE (0, 15, SCR_MAX_X, 15);
Waitdlg (1500, "Now Loading the Program ..."); // show loading ...
SetColor (Black);
Void DrawPic (int StartX, int Starty, Int width = 8, int = 8, int linecolor = LGRAY, BOOL shadow = true, int deep = 3) {int realx, realy; realx = StartX x * width; real = starty y * Height; CRECT Rect (Realx, Realy, RealX Width, Realy Height); Realy Height); Rect.draw (Color, LineColor, Shadow, 5);} void drawm1 (int Direction) , int x, int y, int width = 8, int = 8, int color = green, int linecolor = LGRAY, BOOL shadow = true, int desk = 3) {i (Direction == 1) {DRAWPIC (X, Y, 1, 1, color); DrawPic (X, Y, 0, 2, Color); DrawPic (X, Y, 1, 2, Color); DrawPic (X, Y, 2, 2, Color);} else IF (Direction == 2) {DRAWPIC (X, Y, 1, 1, Color); DrawPic (X, Y, 0, 2, Color); DrawPic (X, Y, 1, 2, Color); DrawPic (X , Y, 1, 3, Color;} else if (Direction == 3) {DRAWPIC (X, Y, 0, 1, Color); DrawPic (X, Y, 1, 1, Color); DrawPic (x, Y, 2, 1, color; DrawPic (x, y, 1, 2, color);} else if (Direction == 4) {DrawPic (x, y, 1, 1, color); DrawPic (x, y , 1, 2, color); DrawPic (X, Y, 1, 3, Color); DrawPic (X, Y, 2, 2, Color);}}
Void Drawm2 (int Direction, int X, int y, int width = 8, int Height = 8, int color = blue, int linecolor = LGRAY, BOOL shadow = true, int desk = 3) {if (Direction == 1) {DrawPic (X, Y, 1, 1, Color); DrawPic (X, Y, 1, 2, Color); DrawPic (x, y, 1, 3, color); DrawPic (x, y, 2, 3, Else if (Direction == 2) {DRAWPIC (X, Y, 2, 1, Color); DrawPic (X, Y, 0, 2, Color); DrawPic (x, y, 1, 2, color) ); DrawPic (x, y, 2, 2, color);} else if (Direction == 3) {DRAWPIC (X, Y, 1, 1, Color); DrawPic (x, y, 2, 1, color) DrawPic (X, Y, 2, 2, Color); DrawPic (x, y, 2, 3, color);} else if (Direction == 4) {DRAWPIC (X, Y, 1, 1, Color); DrawPic (X, Y, 1, 2, Color); DrawPic (X, Y, 2, 2, Color); DrawPic (X, Y, 3, 2, Color);}}
Void Drawm3 (int Direction, Int x, int y, int width = 8, int Height = 8, int color = yellow, int linecolor = LGRAY, BOOL Shadow = true, int desk = 3) {ix (Direction == 1 | Direction == 3) {DRAWPIC (X, Y, 1, 0, Color); DrawPic (X, Y, 1, 1, Color); DrawPic (X, Y, 1, 2, Color); DrawPic (X, Y, 1, 3, color);} else if (Direction == 2 || Direction == 4) {DRAWPIC (X, Y, 0, 2, Color); DrawPic (X, Y, 1, 2, Color) DrawPic (X, Y, 2, 2, Color); DrawPic (x, y, 3, 2, color);}} void Drawm4 (int Direction, int x, int y, int width = 8, int Height = 8 , int color = Magenta, int lineColor = LGRAY, BOOL shadow = true, int debry = 3) {if (Direction == 1 || Direction == 3) {DRAWPIC (X, Y, 1, 1, Color); DrawPic (x, y, 1, 2, color); DrawPic (X, Y, 2, 2, Color); DrawPic (X, Y, 2, 3, Color);} else} (Direction == 2 || Direction = = 4) {DrawPic (X, Y, 1, 1, Color); DrawPic (X, Y, 2, 1, Color); DrawPic (x, y, 0, 2, color); DrawPic (x, y, 1 , 2, color);}}
void DrawImagesXY (int imgType, int imgDirection, int CellX, int CellY, int width = 8, int height = 8, int color = MAGENTA, int lineColor = LGRAY, BOOL shadow = TRUE, int deep = 3) {int x, y ; X = 120 40 * Cellx; y = 40 40 * Celly; if (imgtype == 1) {DRAWM1 (IMGDIRECTION, X, Y);} else if (imgtype == 2) {DRAWM2 (IMGDIRECTION, X, Y);} else if (imgtype == 3) {DRAWM3 (IMGDIRECTION, X, Y);} else if (imgtype == 4) {DRAWM4 (IMGDIRECTION, X, Y);}}
/ / Calculate the inflection point, put it in the TAG array (INT INPUTNUM) {INT P = 0; for (int i = 1; I While (Client <= 100) {while (1) {POS [I] [J] = Client ; IF (POS [i] [j-1] == 0) Break; I -;} j--; while (1) {POS [I] [J] = Client ; IF (POS [i 1] [J] == 0) Break; j -;} i ; while (1) {POS [i] [j] = Client ; IF (POS [i] [j 1] == 0) Break; i ;} J ; while (1) {POS [i] [j] = client ; if (POS [i-1] [J ] == 0) Break; J ;} i -;} for (m = 0; m ) {for (N1 = 0; N1 <10; N1 ) {Printf ("% 2d", POS [ M] [n1]);} printf ("/ n");}} / * -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ----- Function: Found the (YYY, XXX) from Ninput N (1 - 100) Output (YYY, XXX) ---------------------- ------------- * / void getpos (int N) {Int m, n1; for (m = 0; M <10; M ) {for (N1 = 0; N1 <10; N1 ) {IF (POS [M] [N1] == N) {xxx = m; yyy = n1;}}}}