Home Forums C Programming Backgammon

Viewing 0 reply threads
  • Author
    Posts
    • #2189
      OdessaUPFwc
      Participant

      Hi Everybody,
      I have an assignment of creating a backgammon game in c/c++ and in spite of downloading maximum stuffs on the web regarding graphics and c, I have only been able to create the board and make the mouse appear. It is just like drawing a picture with mouse on and nothing more. I will like to get some hints about structuring and giving some life to the board. Can anybody please help. I am looking for a backgammon model in cpp if possible or hints as to how I am going to attack this assignment???

      Thank you in advance,
      Co. :)

      #include<stdio.h>
      #include<conio.h>
      #include<dos.h>
      #include<ctype.h>
      #include<graphics.h>
      union REGS in,out;
      
      int callmouse()
      {
      in.x.ax=1;
      int86(51,&in,&out);
      return 1;
      }
      
      void main()
      
      {
      int gd=DETECT, gm;
      initgraph(&gd, &gm, "c:\tc\bgi");
      callmouse();
      int p0[18]={24,0,36,128,48,0,72,0,84,128,96,0,120,0,132,128,144,0};
      int p1[18]={48,0,54,128,72,0,96,0,108,128,120,0,144,0,156,128,168,0};
      int p2[18]={216,0,228,128,240,0,264,0,276,128,288,0,312,0,324,128,336,0};
      int p3[18]={240,0,252,128,264,0,288,0,300,128,312,0,336,0,348,128,360,0};
      int p4[18]={24,384,36,256,48,384,72,384,84,256,96,384,120,384,132,256,144,384};
      int p5[18]={48,384,60,256,72,384,96,384,108,256,120,384,144,384,156,256,168,384};
      int p6[18]={216,384,228,256,240,384,264,384,276,256,288,384,312,384,324,256,336,384};
      int p7[18]={240,384,252,256,264,384,288,384,300,256,312,384,336,384,348,256,360,384};
      setbkcolor(BLACK);
      setcolor(2);
      rectangle(0,0,415,384);
      rectangle(370,15,405,190);
      rectangle(370,369,405,200);
      line (24,0,24,384);
      line (168,0,168,384);
      line (216,0,216,384);
      line (360,0,360,384);
      
      
      
      /* First v shape */
      setcolor(3);
      drawpoly (9,p0);
      drawpoly (9,p2);
      drawpoly (9,p4);
      drawpoly (9,p6);
      
      
      /* Second V shape */
      setcolor(4);
      drawpoly (9,p1);
      drawpoly (9,p3);
      drawpoly (9,p5);
      drawpoly (9,p7);
      /* filling the v-shape no. 1 */
      setfillstyle (SOLID_FILL, LIGHTBLUE);
      fillpoly (9,p0);
      fillpoly (9,p2);
      fillpoly (9,p4);
      fillpoly (9,p6);
      setfillstyle (SOLID_FILL, LIGHTCYAN);
      fillpoly (9,p1);
      fillpoly (9,p3);
      fillpoly (9,p5);
      fillpoly (9,p7);
      
      
      
      /*1st player*/
      
      setfillstyle(SOLID_FILL, RED);
      setcolor(6);
      
      /*first quadrant*/
      
      fillellipse(36,12,12,12);
      fillellipse(36,36,12,12);
      fillellipse(36,60,12,12);
      fillellipse(36,84,12,12);
      fillellipse(36,108,12,12);
      
      /*2nd quadrant*/
      
      fillellipse(348,12,12,12);
      fillellipse(348,36,12,12);
      
      /* 3rd quadrant */
      fillellipse(132,372,12,12);
      fillellipse(132,348,12,12);
      fillellipse(132,324,12,12);
      
      
      /* 4th quadrant */
      fillellipse(228,372,12,12);
      fillellipse(228,348,12,12);
      fillellipse(228,324,12,12);
      fillellipse(228,300,12,12);
      fillellipse(228,276,12,12);
      
      
      
      
      /* 2nd player*/
      
      setfillstyle(SOLID_FILL, YELLOW);
      setcolor(8);
      
      /*first quadrant*/
      fillellipse(132,12,12,12);
      fillellipse(132,36,12,12);
      fillellipse(132,60,12,12);
      
      /*2nd quadrant*/
      fillellipse(228,12,12,12);
      fillellipse(228,36,12,12);
      fillellipse(228,60,12,12);
      fillellipse(228,84,12,12);
      fillellipse(228,108,12,12);
      
      
      
      /* 3rd quadrant */
      fillellipse(36,372,12,12);
      fillellipse(36,348,12,12);
      fillellipse(36,324,12,12);
      fillellipse(36,300,12,12);
      fillellipse(36,276,12,12);
      
      /* 4th quadrant */
      fillellipse(348,372,12,12);
      fillellipse(348,348,12,12);
      
      
      
      /* message area */
      setcolor(BROWN);
      rectangle(10,427,215,467);
      outtextxy(11,416,"MESSAGE DISPLAY AREA");
      setcolor(WHITE);
      outtextxy(50,440,"BACKGAMMON FURY");
      setcolor(GREEN);
      outtextxy(44,452,"BY CORRINA CELINE");
      
      
      /* scores area */
      setcolor(YELLOW);
      outtextxy(231,416 , "SCORE AREA");
      rectangle(230,427,384,467);
      outtextxy(235,439, "Player:");
      outtextxy(295,439,"1");
      outtextxy(340,439,"2");
      outtextxy(235,454,"Score:");
      
      
      /* Dice */
      setcolor(GREEN);
      outtextxy(244,160, "DICE");
      rectangle(243,172,333,212);
      setcolor(YELLOW);
      setfillstyle(SOLID_FILL,GREEN);
      rectangle(248,177,278,207);
      setcolor(RED);
      setfillstyle(SOLID_FILL,RED);
      rectangle(298,177,328,207);
      
      /* MENU BAR */
      
      setcolor(LIGHTGREEN);
      outtextxy(451,7,"Menu Bar");
      setcolor(LIGHTBLUE);
      rectangle(450,28,530,56);
      outtextxy(459,39,"START");
      
      setcolor(LIGHTMAGENTA);
      rectangle(450,71,530,100);
      outtextxy(459,80,"RESTART");
      
      setcolor(LIGHTRED);
      rectangle(450,114,530,144);
      outtextxy(459,121,"QUIT");
      
      setcolor(YELLOW);
      rectangle(450,157,530,188);
      outtextxy(459,165,"Roll Dice");
      
      setcolor(RED);
      rectangle(450,285,600,316);
      outtextxy(451,270,"PLAYER 1");
      
      setcolor(YELLOW);
      rectangle(450,353,600,384);
      outtextxy(451,338,"PLAYER 2");
      
      
      
      getch();
      closegraph();
      }
      
      
      
      • This topic was modified 1 year, 8 months ago by M. Saqib.

Viewing 0 reply threads
  • The forum ‘C Programming’ is closed to new topics and replies.