Home Forums C Programming draw chess board

Viewing 1 reply thread
  • Author
    Posts
    • #2079
      abhishek3013
      Participant

      please i need a clue on how to start drawing a chess board in dev-c++.

      it seems it does not find the header file . need help.

    • #3360
      msaqib
      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.

      #include 
      #include 
      #include 
      #include 
      
      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;
      }
      
      • This reply was modified 7 years, 6 months ago by M. Saqib.
      • This reply was modified 4 years, 12 months ago by M. Saqib. Reason: Code formatting
      • This reply was modified 4 years, 12 months ago by M. Saqib.
Viewing 1 reply thread
  • The forum ‘C Programming’ is closed to new topics and replies.