Home › Forums › C Programming › draw chess board › Reply To: draw chess board
March 17, 2008 at 5:45 pm
#3360
Participant
Someone has already done the hard work for you :D. So you can use the same graphis.h functions and library. So what you have to do is, https://www.mycplus.com/tutorials/c-programming-tutorials/graphics-programming/ checkout this webpage, read through it, and download the gaphics library and graphics.h header file.
Next step is to read the manual on how to prepare you project to use this library. And thats it, you are done.
Here is a simple graphics program which i wrote for my Borland compiler 3. But the same program without any modifications is working fine on Dev-C++ 4.9.
C
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 | #include <stdio.h> #include <graphics.h> #include <conio.h> #include <process.h> int main(void) { int mx, my; /* request auto detection */ int gd= DETECT, gm, errorcode; initgraph(&gd,&gm,"F:\tc\bgi"); //Last argument is the path to the graphics library of Turbo C /* read result of initialization */ errorcode = graphresult(); if (errorcode != grOk) /* an error occurred */ { printf("Graphics error: %sn", grapherrormsg(errorcode)); printf("Press any key to halt:"); getch(); exit(1); /* return with error code */ } mx = (getmaxx() / 2); my = (getmaxy() / 2); //SET baqckground color setfillstyle(9, 1); bar(0,0,getmaxx(),getmaxy()); //DRAW a bar, and make it look like a 3d bar setfillstyle(1,7); //bar(50,20,600,400); //DRAW lines for the top and left side setcolor(15); line(50,20,600,20); line(51,21,599,21); line(50,20,50,400); line(51,21,51,399); //DRAW lines for the bottom and right side setcolor(8); line(600,20,600,400); line(599,21,599,400); line(50,400,600,400); line(51,399,600,399); //DRAW two 3D bars for the left and right side setfillstyle(9,8); bar(70,40,100,380); bar(70,40,550,70); bar(70,350,550,379); bar(545,40,575,380); settextstyle(1, 0, 4); settextjustify(1,1); setcolor(LIGHTGREEN); outtextxy(mx+2, my - 46, "Graphics - Dev-C++"); setcolor(LIGHTGREEN); outtextxy(mx + 1, my - 45, "Graphics - Dev-C++"); setcolor(GREEN); outtextxy(mx + 2, my - 44, "Graphics - Dev-C++"); //PRINT 3D text 2008 setcolor(LIGHTGREEN); outtextxy(mx, my + 10, "2008"); setcolor(LIGHTGREEN); outtextxy(mx + 1, my + 11, "2008"); setcolor(GREEN); outtextxy(mx + 2, my + 12, "2008"); getch(); //PAUSE for a while closegraph(); return 0; } |