Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <graphics.h>
- #include <winbgim.h>
- #include <conio.h>
- #include <windows.h>
- #include <math.h>
- using namespace std;
- #define pod_p1 10
- #define pod_p2 20
- #define BLUE_COLOR_Player1 1
- #define GREEN_COLOR_Player1 10
- #define PINK_COLOR_Player1 13
- #define RED_COLOR_Player2 4
- #define YELLOR_COLOR_Player2 14
- #define GRAY_COLOR_Player2 7
- int radius,Player1_Color_Choice=BLUE_COLOR_Player1, Player2_Color_Choice=RED_COLOR_Player2;
- int window_lenght =1000;
- int window_height=600;
- int teren[120][120];
- int board_Size=6;
- bool Player1_WON=FALSE, Player2_WON=FALSE;
- void initMatrice(int teren[120][120],int n)
- {
- int i,j;
- for(i=1; i<=2*board_Size-1; i++)
- for (j=1; j<=2*board_Size-1; j++)
- {
- if(j%2==1 && i%2==0)
- {
- teren[i][j]=1;
- teren[j][i]=2;
- }
- }
- for(i=0; i<2*board_Size+1; i++)
- teren[i][0]=teren[0][i]=teren[2*n][i]=teren[i][2*n]=-1;
- }
- void init_Matrice_Vizitare(int v[120][120])
- {
- int i;
- for (i=1; i<=2*board_Size; i++)
- for(int j=1;i<=2*board_Size;j++)
- v[i][j]=0;
- }
- /*void parcurgere_adancime_p1 (int linie, int coloana)
- {
- if (coloana==2*n-1)
- Player1_WON= TRUE;
- if(teren[linie][coloana+1]==10)
- parcurgere_adancime_p1(linie, coloana+2);
- else
- if(teren[linie-1][coloana]==10)
- parcurgere_adancime_p1(linie-2, coloana);
- else
- if(teren[linie+1][coloana]==10)
- parcurgere_adancime_p1(linie+2,coloana);
- else
- if(teren[linie][coloana-1]==10)
- parcurgere_adancime_p1(linie, coloana-2);
- }
- int parcurgere_adancime_p2 (int k)
- {
- v_p2[k]=1;
- if (k==2*n) return k;
- for(int x=0;x<2*n;x=x+2)
- if(teren [k][x]==1)
- if(v_p2[x]==0)
- parcurgere_adancime_p2 (x); else return x;
- }
- int verifica_castigator ()
- {
- int i;
- for (i=2; i<=2*n-2; i=i+2)
- {
- //init_Matrice_Vizitare(vizitat_p1);
- parcurgere_adancime_p1(i,1);
- if(Player1_WON)
- return 1;
- }
- /*for (i=0;i<=2*n;i=i+2)
- {
- init(v_p2); if (parcurgere_adancime_p2(i)==2*n) return 2;
- }
- return 0;
- }
- */
- void creazaPod(int i, int j, char *dir)
- {
- if (strcmp(dir, "sus")==0)
- {
- if (teren[i-1][j]==0 )
- {
- if(j%2==1 && i%2==0 && i!=1)
- {
- teren[i-1][j]=pod_p1;
- setcolor(Player1_Color_Choice);
- line(window_lenght/4 + ((window_lenght/2)/board_Size)*(j/2) +window_lenght/(4*board_Size),window_height/4 + ((window_height/2)/board_Size)*(i/2), window_lenght/4 + ((window_lenght/2)/board_Size)*(j/2) + window_lenght/(4*board_Size),window_height/4 + ((window_height/2)/board_Size)*(i/2-1));
- line(1+window_lenght/4 + ((window_lenght/2)/board_Size)*(j/2) +window_lenght/(4*board_Size),window_height/4 + ((window_height/2)/board_Size)*(i/2),1+ window_lenght/4 + ((window_lenght/2)/board_Size)*(j/2) + window_lenght/(4*board_Size),window_height/4 + ((window_height/2)/board_Size)*(i/2-1));
- line(-1 + window_lenght/4 + ((window_lenght/2)/board_Size)*(j/2) +window_lenght/(4*board_Size),window_height/4 + ((window_height/2)/board_Size)*(i/2),-1 + window_lenght/4 + ((window_lenght/2)/board_Size)*(j/2) + window_lenght/(4*board_Size),window_height/4 + ((window_height/2)/board_Size)*(i/2-1));
- }
- else if(j%2==0 && i%2==1 && i!=2)
- {
- teren[i-1][j]=pod_p2;
- setcolor(Player2_Color_Choice);
- line(window_lenght/4 + ((window_lenght/2)/board_Size)*(j/2),window_height/4 + ((window_height/2)/board_Size)*(i/2) + (window_height/4)/board_Size, window_lenght/4 + ((window_lenght/2)/board_Size)*(j/2),window_height/4 + ((window_height/2)/board_Size)*(i/2-1) +(window_height/4)/board_Size);
- line(1+window_lenght/4 + ((window_lenght/2)/board_Size)*(j/2),window_height/4 + ((window_height/2)/board_Size)*(i/2) + (window_height/4)/board_Size,1+ window_lenght/4 + ((window_lenght/2)/board_Size)*(j/2),window_height/4 + ((window_height/2)/board_Size)*(i/2-1) +(window_height/4)/board_Size);
- line(-1 +window_lenght/4 + ((window_lenght/2)/board_Size)*(j/2),window_height/4 + ((window_height/2)/board_Size)*(i/2) + (window_height/4)/board_Size,-1 + window_lenght/4 + ((window_lenght/2)/board_Size)*(j/2),window_height/4 + ((window_height/2)/board_Size)*(i/2-1) +(window_height/4)/board_Size);
- }
- }
- }
- if (strcmp(dir, "jos")==0)
- {
- if (teren[i+1][j]==0)
- {
- if(j%2==1 && i%2==0 && i!=2*board_Size-2)
- {
- teren[i+1][j]=pod_p1;
- setcolor(Player1_Color_Choice);
- line(window_lenght/4 + ((window_lenght/2)/board_Size)*(j/2) +window_lenght/(4*board_Size),window_height/4 + ((window_height/2)/board_Size)*(i/2), window_lenght/4 + ((window_lenght/2)/board_Size)*(j/2) + window_lenght/(4*board_Size),window_height/4 + ((window_height/2)/board_Size)*(i/2+1));
- line(1+window_lenght/4 + ((window_lenght/2)/board_Size)*(j/2) +window_lenght/(4*board_Size),window_height/4 + ((window_height/2)/board_Size)*(i/2),1+ window_lenght/4 + ((window_lenght/2)/board_Size)*(j/2) + window_lenght/(4*board_Size),window_height/4 + ((window_height/2)/board_Size)*(i/2+1));
- line(-1+window_lenght/4 + ((window_lenght/2)/board_Size)*(j/2) +window_lenght/(4*board_Size),window_height/4 + ((window_height/2)/board_Size)*(i/2),-1+ window_lenght/4 + ((window_lenght/2)/board_Size)*(j/2) + window_lenght/(4*board_Size),window_height/4 + ((window_height/2)/board_Size)*(i/2+1));
- }
- else if(j%2==0 && i%2==1 && i!=2*board_Size-1)
- {
- teren[i+1][j]=pod_p2;
- setcolor(Player2_Color_Choice);
- line(window_lenght/4 + ((window_lenght/2)/board_Size)*(j/2),window_height/4 + ((window_height/2)/board_Size)*(i/2) + (window_height/4)/board_Size, window_lenght/4 + ((window_lenght/2)/board_Size)*(j/2),window_height/4 + ((window_height/2)/board_Size)*(i/2+1) +(window_height/4)/board_Size);
- line(1+window_lenght/4 + ((window_lenght/2)/board_Size)*(j/2),window_height/4 + ((window_height/2)/board_Size)*(i/2) + (window_height/4)/board_Size,1 + window_lenght/4 + ((window_lenght/2)/board_Size)*(j/2),window_height/4 + ((window_height/2)/board_Size)*(i/2+1) +(window_height/4)/board_Size);
- line(-1+window_lenght/4 + ((window_lenght/2)/board_Size)*(j/2),window_height/4 + ((window_height/2)/board_Size)*(i/2) + (window_height/4)/board_Size,-1 + window_lenght/4 + ((window_lenght/2)/board_Size)*(j/2),window_height/4 + ((window_height/2)/board_Size)*(i/2+1) +(window_height/4)/board_Size);
- }
- }
- }
- if (strcmp(dir, "st")==0)
- {
- if (teren[i][j-1]==0 )
- if(j%2==1 && i%2==0 && j!=1)
- {
- teren[i][j-1]=pod_p1;
- setcolor(Player1_Color_Choice);
- line(window_lenght/4 + ((window_lenght/2)/board_Size)*(j/2) +window_lenght/(4*board_Size),window_height/4 + ((window_height/2)/board_Size)*(i/2 ), window_lenght/4 + ((window_lenght/2)/board_Size)*(j/2-1) + window_lenght/(4*board_Size),window_height/4 + ((window_height/2)/board_Size)*(i/2));
- line(window_lenght/4 + ((window_lenght/2)/board_Size)*(j/2) +window_lenght/(4*board_Size),1+window_height/4 + ((window_height/2)/board_Size)*(i/2 ), window_lenght/4 + ((window_lenght/2)/board_Size)*(j/2-1) + window_lenght/(4*board_Size),1+window_height/4 + ((window_height/2)/board_Size)*(i/2));
- line(window_lenght/4 + ((window_lenght/2)/board_Size)*(j/2) +window_lenght/(4*board_Size),-1 +window_height/4 + ((window_height/2)/board_Size)*(i/2 ), window_lenght/4 + ((window_lenght/2)/board_Size)*(j/2-1) + window_lenght/(4*board_Size),-1+window_height/4 + ((window_height/2)/board_Size)*(i/2));
- }
- else if(j%2==0 && i%2==1 && j!=2)
- {
- teren[i][j-1]=pod_p2;
- setcolor(Player2_Color_Choice);
- line(window_lenght/4 + ((window_lenght/2)/board_Size)*(j/2),window_height/4 + ((window_height/2)/board_Size)*(i/2 ) +(window_height/4)/board_Size, window_lenght/4 + ((window_lenght/2)/board_Size)*(j/2-1),window_height/4 + ((window_height/2)/board_Size)*(i/2) +(window_height/4)/board_Size);
- line(window_lenght/4 + ((window_lenght/2)/board_Size)*(j/2),1+window_height/4 + ((window_height/2)/board_Size)*(i/2 ) +(window_height/4)/board_Size, window_lenght/4 + ((window_lenght/2)/board_Size)*(j/2-1),1+ window_height/4 + ((window_height/2)/board_Size)*(i/2) +(window_height/4)/board_Size);
- line(window_lenght/4 + ((window_lenght/2)/board_Size)*(j/2),-1 +window_height/4 + ((window_height/2)/board_Size)*(i/2 ) +(window_height/4)/board_Size, window_lenght/4 + ((window_lenght/2)/board_Size)*(j/2-1),-1 + window_height/4 + ((window_height/2)/board_Size)*(i/2) +(window_height/4)/board_Size);
- }
- }
- if (strcmp(dir, "dr")==0)
- {
- if (teren[i][j+1]==0 )
- if(j%2==1 && i%2==0 && j!= 2*board_Size -1)
- {
- teren[i][j+1]=pod_p1;
- setcolor(Player1_Color_Choice);
- line(window_lenght/4 + ((window_lenght/2)/board_Size)*(j/2) +window_lenght/(4*board_Size),window_height/4 + ((window_height/2)/board_Size)*(i/2 ), window_lenght/4 + ((window_lenght/2)/board_Size)*(j/2+1) + window_lenght/(4*board_Size),window_height/4 + ((window_height/2)/board_Size)*(i/2));
- line(window_lenght/4 + ((window_lenght/2)/board_Size)*(j/2) +window_lenght/(4*board_Size),1+window_height/4 + ((window_height/2)/board_Size)*(i/2 ), window_lenght/4 + ((window_lenght/2)/board_Size)*(j/2+1) + window_lenght/(4*board_Size),1 +window_height/4 + ((window_height/2)/board_Size)*(i/2));
- line(window_lenght/4 + ((window_lenght/2)/board_Size)*(j/2) +window_lenght/(4*board_Size),-1 + window_height/4 + ((window_height/2)/board_Size)*(i/2 ), window_lenght/4 + ((window_lenght/2)/board_Size)*(j/2+1) + window_lenght/(4*board_Size),-1 + window_height/4 + ((window_height/2)/board_Size)*(i/2));
- }
- else if(j%2==0 && i%2==1 && j!=2*board_Size-2)
- {
- teren[i][j+1]=pod_p2;
- setcolor(Player2_Color_Choice);
- line(window_lenght/4 + ((window_lenght/2)/board_Size)*(j/2),window_height/4 + ((window_height/2)/board_Size)*(i/2 ) +(window_height/4)/board_Size, window_lenght/4 + ((window_lenght/2)/board_Size)*(j/2+1),window_height/4 + ((window_height/2)/board_Size)*(i/2) +(window_height/4)/board_Size);
- line(window_lenght/4 + ((window_lenght/2)/board_Size)*(j/2),1+window_height/4 + ((window_height/2)/board_Size)*(i/2 ) +(window_height/4)/board_Size, window_lenght/4 + ((window_lenght/2)/board_Size)*(j/2+1),1+window_height/4 + ((window_height/2)/board_Size)*(i/2) +(window_height/4)/board_Size);
- line(window_lenght/4 + ((window_lenght/2)/board_Size)*(j/2),-1 + window_height/4 + ((window_height/2)/board_Size)*(i/2 ) +(window_height/4)/board_Size, window_lenght/4 + ((window_lenght/2)/board_Size)*(j/2+1),-1 +window_height/4 + ((window_height/2)/board_Size)*(i/2) +(window_height/4)/board_Size);
- }
- }
- }
- bool apasatInCercPl1(int &x,int &y)
- {
- for(int i=1; i<=board_Size; i++)
- for(int j=1; j<board_Size; j++)
- if((x>(window_lenght/4- ((window_lenght/4)/board_Size) + ((window_lenght/2)/board_Size)*i - radius)) && (x<window_lenght/4- ((window_lenght/4)/board_Size) + ((window_lenght/2)/board_Size)*i + radius ))
- if((y>(window_height/4 +((window_height/4)/board_Size) + ((window_height/2)/board_Size)*j - 3*radius)) && (y<(window_height/4 +((window_height/4)/board_Size) + ((window_height/2)/board_Size)*j - radius)))
- {
- x=i;
- y=j;
- return 1;
- }
- return 0;
- }
- bool is_Above_the_First(int x1,int y1,int x2,int y2)
- {
- if((x2>x1-radius && x2 < x1+radius) && (y2>y1 - window_height/(2*board_Size) - radius && y2<y1 - window_height/(2*board_Size) + radius) )
- {
- return 1;
- }
- else
- return 0;
- }
- bool is_Under_the_First(int x1, int y1, int x2, int y2)
- {
- if((x2>x1-radius && x2 < x1+radius) && (y2>y1 + window_height/(2*board_Size) - radius && y2<y1 + window_height/(2*board_Size) + radius) )
- {
- return 1;
- }
- else
- return 0;
- }
- bool is_in_Right_of_First(int x1, int y1, int x2, int y2)
- {
- if((x2>x1-radius + window_lenght/(2*board_Size) && x2 < x1+radius + window_lenght/(2*board_Size)) && (y2>y1 - radius && y2<y1 + radius) )
- {
- return 1;
- }
- else
- return 0;
- }
- bool is_in_Left_of_First(int x1, int y1, int x2, int y2)
- {
- if((x2>x1-radius - window_lenght/(2*board_Size) && x2 < x1+radius - window_lenght/(2*board_Size)) && (y2>y1 - radius && y2<y1 + radius) )
- {
- return 1;
- }
- else
- return 0;
- }
- void highlight_Possible_Bridges(int linie, int coloana)
- {
- if(1);
- }
- void player1_Move()
- {
- int x1,x2,y1,y2,coloana,linie;
- bool lineWasDrawn=FALSE, selectedAproperPosition=FALSE ;
- while(!lineWasDrawn)
- {
- while(!selectedAproperPosition)
- if(ismouseclick(WM_LBUTTONDOWN))
- {
- clearmouseclick(WM_LBUTTONDOWN);
- coloana=mousex();
- linie=mousey();
- if(apasatInCercPl1(coloana,linie) )
- {
- x1=mousex();
- y1=mousey();
- selectedAproperPosition=TRUE;
- }
- }
- selectedAproperPosition=FALSE;
- while(!selectedAproperPosition)
- {
- if(ismouseclick(WM_LBUTTONDOWN))
- {
- clearmouseclick(WM_LBUTTONDOWN);
- int x2=mousex(),y2=mousey();
- if(is_Above_the_First(x1,y1,x2,y2)==1 && teren[2*linie-1][2*coloana-1] ==0)
- {
- creazaPod(2*linie,2*coloana -1,"sus");
- lineWasDrawn=TRUE;
- selectedAproperPosition=TRUE;
- }
- else if(is_Under_the_First(x1,y1,x2,y2) && teren[2*linie+1][2*coloana-1] ==0)
- {
- creazaPod(2*linie,2*coloana -1,"jos");
- lineWasDrawn=TRUE;
- selectedAproperPosition=TRUE;
- }
- else if(is_in_Right_of_First(x1,y1,x2,y2) && teren[2*linie][2*coloana] ==0)
- {
- creazaPod(2*linie,2*coloana -1,"dr");
- lineWasDrawn=TRUE;
- selectedAproperPosition=TRUE;
- }
- else if (is_in_Left_of_First(x1,y1,x2,y2)&& teren[2*linie][2*coloana-2] ==0)
- {
- creazaPod(2*linie,2*coloana -1,"st");
- lineWasDrawn=TRUE;
- selectedAproperPosition=TRUE;
- }
- else {coloana=mousex();
- linie=mousey();
- if(apasatInCercPl1(coloana,linie) )
- {
- x1=mousex();
- y1=mousey();
- selectedAproperPosition=TRUE;
- }
- }
- }
- }
- }
- }
- bool apasatInCercPl2(int &x,int &y)
- {
- for(int i=1; i<board_Size; i++)
- for(int j=1; j<=board_Size; j++)
- if((x>window_lenght/4 + ((window_lenght/2)/board_Size)*i - radius) && (x<window_lenght/4 + ((window_lenght/2)/board_Size)*i + radius ))
- {
- if((y>( window_height/4 + ((window_height/2)/board_Size)*j - 3*radius)) && (y<( window_height/4 + ((window_height/2)/board_Size)*j - radius)))
- {
- x=i;
- y=j;
- return 1;
- }
- }
- return 0;
- }
- void player2_Move()
- {
- int x1,x2,y1,y2,coloana,linie;
- bool lineWasDrawn=FALSE, selectedAproperPosition=FALSE ;
- while(!lineWasDrawn)
- {
- while(!selectedAproperPosition)
- if(ismouseclick(WM_LBUTTONDOWN))
- {
- clearmouseclick(WM_LBUTTONDOWN);
- coloana=mousex();
- linie=mousey();
- if(apasatInCercPl2(coloana,linie) )
- {
- x1=mousex();
- y1=mousey();
- selectedAproperPosition=TRUE;
- }
- }
- selectedAproperPosition=FALSE;
- while(!selectedAproperPosition)
- {
- if(ismouseclick(WM_LBUTTONDOWN))
- {
- clearmouseclick(WM_LBUTTONDOWN);
- int x2=mousex(),y2=mousey();
- if(is_Above_the_First(x1,y1,x2,y2)==1 && teren[2*linie-2][2*coloana] ==0 )
- {
- creazaPod(2*linie-1,2*coloana ,"sus");
- lineWasDrawn=TRUE;
- selectedAproperPosition=TRUE;
- }
- else if(is_Under_the_First(x1,y1,x2,y2) && teren[2*linie][2*coloana] ==0)
- {
- creazaPod(2*linie-1,2*coloana ,"jos");
- lineWasDrawn=TRUE;
- selectedAproperPosition=TRUE;
- }
- else if(is_in_Right_of_First(x1,y1,x2,y2) && teren[2*linie-1][2*coloana+1] ==0)
- {
- creazaPod(2*linie-1,2*coloana,"dr");
- lineWasDrawn=TRUE;
- selectedAproperPosition=TRUE;
- }
- else if (is_in_Left_of_First(x1,y1,x2,y2)&& teren[2*linie-1][2*coloana-1] ==0)
- {
- creazaPod(2*linie-1,2*coloana ,"st");
- lineWasDrawn=TRUE;
- selectedAproperPosition=TRUE;
- }
- else {
- coloana=mousex();
- linie=mousey();
- if(apasatInCercPl2(coloana,linie) )
- {
- x1=mousex();
- y1=mousey();
- selectedAproperPosition=TRUE;
- }
- }
- }
- }
- }
- }
- void initTable(short int board_Size, int Player1_Color_Choice, int Player2_Color_Choice)
- {
- int i,j, c[]= {250,150,750,150,750,450,250,450,250,150},c2[]= {0,0,1000,0,1000,600,0,600,0,0};
- setfillstyle(SOLID_FILL,WHITE);
- fillpoly(5,c2);
- setfillstyle(SOLID_FILL,BLACK);
- fillpoly(5,c);
- setcolor(Player1_Color_Choice);
- setfillstyle(SOLID_FILL,Player1_Color_Choice);
- for(i=1; i<=board_Size; i++)
- for(j=1; j<board_Size; j++)
- fillellipse( (window_lenght/4)- ((window_lenght/4)/board_Size) + ((window_lenght/2)/board_Size)*i,window_height/4 +((window_height/4)/board_Size) + ((window_height/2)/board_Size)*j - 2*radius, radius,radius);
- setcolor(Player2_Color_Choice);
- setfillstyle(SOLID_FILL,Player2_Color_Choice);
- for(i=1; i<board_Size; i++)
- for(j=1; j<=board_Size; j++)
- fillellipse( window_lenght/4 + ((window_lenght/2)/board_Size)*i, window_height/4 + ((window_height/2)/board_Size)*j - 2*radius, radius,radius);
- setcolor(BLACK);
- setbkcolor(WHITE);
- settextstyle(BOLD_FONT,HORIZ_DIR,7);
- outtextxy(350,75,"BRIDG-IT");
- }
- void draw_Instructions_Page()
- {
- int c2[]= {0,0,1000,0,1000,600,0,600,0,0};
- setfillstyle(SOLID_FILL,BLACK);
- fillpoly(5,c2);
- settextstyle(BOLD_FONT,HORIZ_DIR, 3);
- setcolor(LIGHTGREEN);
- setbkcolor(BLACK);
- outtextxy(window_lenght/3 - 70, window_height/5 -30, "What is Bridg-It?");
- outtextxy(window_lenght/3-70, window_height/5 + 100, "Rules:" );
- outtextxy(window_lenght/4+10,window_height/5+190, "Controls: ");
- settextstyle(BOLD_FONT,HORIZ_DIR, 1);
- setcolor(YELLOW);
- outtextxy(window_lenght/4, window_height/5 , "Bridg-It is a simple *connect the dots* board game");
- outtextxy(window_lenght/4, window_height/5 + 15, "where players take turns");
- outtextxy(window_lenght/4,window_height/5+30, "trying to connect as many of their dots");
- outtextxy(window_lenght/4,window_height/5+45, "with the ultimate goal of connecting");
- outtextxy(window_lenght/4,window_height/5+60, "the left side to the right side for Player 1");
- outtextxy(window_lenght/4,window_height/5+75, "respectively top to bottom for Player 2.");
- outtextxy(window_lenght/4,window_height/5+120, "-You draw 1 bridge at a time BETWEEN YOUR DOTS");
- outtextxy(window_lenght/4,window_height/5+135, "-You cannot draw a bridge in a place where there already is one");
- outtextxy(window_lenght/4,window_height/5+150, "-Player 1 wins if he manages to get from left to right");
- outtextxy(window_lenght/4,window_height/5+165, "-Player2 wins if he manages to get from top to bottom ");
- outtextxy(window_lenght/4,window_height/5+210, "You mouse-click on the dot that you want to connect with another");
- outtextxy(window_lenght/4,window_height/5+225, "then on the one you want it connected with");
- int c[]={window_lenght/2-100,window_height/5 +260, window_lenght/2+100, window_height/5+260, window_lenght/2 +100, window_height/5+300,window_lenght/2-100,window_height/5+300, window_lenght/2-100,window_height/5 +260};
- setfillstyle(SOLID_FILL,LIGHTGRAY);
- fillpoly(5,c);
- setbkcolor(LIGHTGRAY);
- setcolor(BLUE);
- outtextxy(window_lenght/2-95, window_height/5+270, "BACK TO MAIN MENU");
- }
- void main_Menu();
- void instructions_Page()
- {
- cleardevice();
- draw_Instructions_Page();
- bool selectedBackToMM = FALSE;
- while(!selectedBackToMM)
- if(ismouseclick(WM_LBUTTONDOWN))
- {
- clearmouseclick(WM_LBUTTONDOWN);
- if(mousex()> window_lenght/2-100 && mousex()<window_lenght/2+100)
- if(mousey()>window_height/5+260 && mousey()< window_height/5 +300)
- {
- cleardevice();
- selectedBackToMM=TRUE;
- }
- }
- }
- void draw_Play_Menu()
- {
- int c[]= {window_lenght/2-130,window_height/3,window_lenght/2+130,window_height/3,window_lenght/2+130,window_height/3+30,window_lenght/2-130,window_height/3+30,window_lenght/2-130,window_height/3};
- int c2[]= {0,0,1000,0,1000,600,0,600,0,0};
- setfillstyle(SOLID_FILL,BLACK);
- fillpoly(5,c2);
- setfillstyle(SOLID_FILL,LIGHTGRAY);
- setbkcolor(LIGHTGRAY);
- fillpoly(5,c);
- c[1]+=50; c[3]+=50;c[5]+=50;c[7]+=50; c[9]+=50;
- fillpoly(5,c);
- c[1]+=100; c[3]+=100;c[5]+=120;c[7]+=120; c[9]+=100;
- fillpoly(5,c);
- c[1]+=70; c[3]+=70;c[5]+=50;c[7]+=50; c[9]+=70;
- fillpoly(5,c);
- setcolor(BLACK);
- line(window_lenght/2-80,window_height/3+150,window_lenght/2-80,window_height/3+200);
- line(window_lenght/2+80,window_height/3+150,window_lenght/2+80,window_height/3+200);
- line(window_lenght/2-79,window_height/3+150,window_lenght/2-79,window_height/3+200);
- line(window_lenght/2+81,window_height/3+150,window_lenght/2+81,window_height/3+200);
- line(window_lenght/2-81,window_height/3+150,window_lenght/2-81,window_height/3+200);
- line(window_lenght/2+79,window_height/3+150,window_lenght/2+79,window_height/3+200);
- settextstyle(BOLD_FONT,HORIZ_DIR,5);
- outtextxy(window_lenght/2-117, window_height/3+155, "-");
- outtextxy(window_lenght/2+95, window_height/3+155, "+");
- setcolor(BLUE);
- settextstyle(BOLD_FONT,HORIZ_DIR,1);
- outtextxy(window_lenght/2-110,window_height/3+7,"PLAYER VERSUS PLAYER");
- outtextxy(window_lenght/2-122,window_height/3+57,"PLAYER VERSUS COMPUTER");
- outtextxy(window_lenght/2-95, window_height/3+227, "BACK TO MAIN MENU");
- settextstyle(BOLD_FONT,HORIZ_DIR,4);
- setcolor(BLUE);
- bgiout<<board_Size;
- outstreamxy(window_lenght/2-3, window_height/3+162);
- settextstyle(BOLD_FONT,HORIZ_DIR, 7);
- setcolor(YELLOW);
- setbkcolor(BLACK);
- outtextxy(window_lenght/3-110,window_height/4-70, "PLAYING OPTIONS");
- settextstyle(BOLD_FONT,HORIZ_DIR,3);
- setcolor(RED);
- outtextxy(window_lenght/2-120,window_height/3+120,"CHOOSE BOARD SIZE");
- settextstyle(BOLD_FONT,HORIZ_DIR,1);
- outtextxy(window_lenght/4-110, window_height/3+20, "CHOOSE PLAYER1 COLOR");
- outtextxy(window_lenght-360, window_height/3+20, "CHOOSE PLAYER2 COLOR");
- setcolor(BLUE_COLOR_Player1);
- setfillstyle(SOLID_FILL,BLUE_COLOR_Player1);
- setcolor(BLUE_COLOR_Player1);
- fillellipse(window_lenght/4-50, window_height/3+65, 15, 15);
- setcolor(GREEN_COLOR_Player1);
- setfillstyle(SOLID_FILL,GREEN_COLOR_Player1);
- setcolor(GREEN_COLOR_Player1);
- fillellipse(window_lenght/4, window_height/3+65, 15, 15);
- setcolor(PINK_COLOR_Player1);
- setfillstyle(SOLID_FILL,PINK_COLOR_Player1);
- setcolor(PINK_COLOR_Player1);
- fillellipse(window_lenght/4+50, window_height/3+65, 15, 15);
- setcolor(RED_COLOR_Player2);
- setfillstyle(SOLID_FILL,RED_COLOR_Player2);
- setcolor(RED_COLOR_Player2);
- fillellipse(window_lenght-300, window_height/3+65, 15, 15);
- setcolor(YELLOR_COLOR_Player2);
- setfillstyle(SOLID_FILL,YELLOR_COLOR_Player2);
- setcolor(YELLOR_COLOR_Player2);
- fillellipse(window_lenght-250, window_height/3+65, 15, 15);
- setcolor(GRAY_COLOR_Player2);
- setfillstyle(SOLID_FILL,GRAY_COLOR_Player2);
- setcolor(GRAY_COLOR_Player2);
- fillellipse(window_lenght-200, window_height/3+65, 15, 15);
- }
- void start_PVP_Game()
- {
- cleardevice();
- initMatrice(teren, board_Size);
- radius= (board_Size<16 && board_Size!=12 && board_Size!= 13)? (25-(2*board_Size)) : 3;
- initTable(board_Size,Player1_Color_Choice, Player2_Color_Choice);
- while(1)
- {
- player1_Move();
- player2_Move();
- for(int i=0; i<=2*board_Size; i++)
- {
- for(int j=0; j<=2*board_Size; j++)
- cout<<teren[i][j]<<' ';
- cout<<endl;
- }
- }
- }
- void play_Menu()
- {
- draw_Play_Menu();
- bool selectedOption = FALSE;
- while(!selectedOption)
- if(ismouseclick(WM_LBUTTONDOWN))
- {
- clearmouseclick(WM_LBUTTONDOWN);
- if (mousex()>window_lenght/2-130 && mousex()<window_lenght/2+130)
- if(mousey()>window_height/3 && mousey()<window_height/3 +30)
- {
- start_PVP_Game();
- cleardevice();
- selectedOption=TRUE;
- }
- if (mousex()>window_lenght/2-130 && mousex()<window_lenght/2-80)
- if(mousey()>window_height/3+150 && mousey()<window_height/3 +180)
- if(board_Size>=4)
- {
- board_Size--;
- setbkcolor(LIGHTGRAY);
- settextstyle(BOLD_FONT,HORIZ_DIR,4);
- setcolor(BLUE);
- bgiout<<board_Size;
- outstreamxy(window_lenght/2-3, window_height/3+162);
- setcolor(WHITE);
- }
- if (mousex()>window_lenght/2+80 && mousex()<window_lenght/2+130)
- if(mousey()>window_height/3+150 && mousey()<window_height/3 +180)
- if(board_Size<20)
- {
- board_Size++;
- setbkcolor(LIGHTGRAY);
- settextstyle(BOLD_FONT,HORIZ_DIR,4);
- setcolor(BLUE);
- bgiout<<board_Size;
- outstreamxy(window_lenght/2-3, window_height/3+162);
- setcolor(BLUE);
- }
- if(mousey()>window_height/3+50 && mousey()<window_height/3+80)
- {if(mousex()>window_lenght/4-65 && mousex()<window_lenght/4-35)
- { Player1_Color_Choice=BLUE;}
- else if(mousex()>window_lenght/4-15 && mousex()<window_lenght/4+15)
- { Player1_Color_Choice=LIGHTGREEN; }
- else if(mousex()>window_lenght/4+35 && mousex()<window_lenght/4+65)
- { Player1_Color_Choice=LIGHTMAGENTA;}
- else if(mousex()>window_lenght-315 && mousex()<window_lenght-285)
- { Player2_Color_Choice=RED;}
- else if (mousex()>window_lenght-265 && mousex()<window_lenght-235)
- { Player2_Color_Choice=YELLOW; }
- else if(mousex()>window_lenght-215 &&mousex()<window_lenght-185)
- { Player2_Color_Choice=LIGHTGRAY; }
- }
- if (mousex()>window_lenght/2-130 && mousex()<window_lenght/2+130)
- if(mousey()>window_height/3+220 && mousey()<window_height/3 +250)
- {
- cleardevice();
- selectedOption=TRUE;
- }
- }
- }
- void draw_Main_Menu()
- {
- int c[]= {window_lenght/2 - 55,window_height/3 - 15,window_lenght/2 + 55,window_height/3 - 15,window_lenght/2 + 55,window_height/3 + 15,window_lenght/2 - 55,window_height/3 + 15 , window_lenght/2 - 55,window_height/3 - 15};
- int c2[]= {0,0,1000,0,1000,600,0,600,0,0};
- setfillstyle(SOLID_FILL,BLACK);
- fillpoly(5,c2);
- setfillstyle(SOLID_FILL,LIGHTGRAY);
- fillpoly(5,c);
- c[0]-=60; c[1]+= 60; c[2]+=60; c[3]+=60; c[4]+=60; c[5]+=60; c[6]-=60; c[7]+=60; c[8]-= 60; c[9]+=60;
- fillpoly(5,c);
- c[0]+=70; c[1]+= 60; c[2]-=70; c[3]+=60; c[4]-=70; c[5]+=60; c[6]+=70; c[7]+=60; c[8]+= 70; c[9]+=60;
- fillpoly(5,c);
- setcolor(BLUE);
- settextstyle(EUROPEAN_FONT,HORIZ_DIR,2);
- setbkcolor(LIGHTGRAY);
- outtextxy(window_lenght/2 - 37,window_height/3 - 10 ,"PLAY");
- outtextxy(window_lenght/2 -105 , window_height/3+50, "INSTRUCTIONS");
- settextstyle(BOLD_FONT,HORIZ_DIR, 5);
- setcolor(YELLOW);
- setbkcolor(BLACK);
- outtextxy(40, 100, "WELCOME TO THE BOARD GAME OF BRIDG-IT");
- setcolor(RED);
- setbkcolor(LIGHTGRAY);
- settextstyle(EUROPEAN_FONT,HORIZ_DIR,2);
- outtextxy(window_lenght/2 - 35, window_height/3 + 110, "QUIT");
- }
- void main_Menu()
- {
- draw_Main_Menu();
- bool selectedOption = FALSE;
- while(!selectedOption)
- if(ismouseclick(WM_LBUTTONDOWN))
- {
- clearmouseclick(WM_LBUTTONDOWN);
- if(mousex()> window_lenght/2-55 && mousex()<window_lenght/2+55)
- if(mousey()> window_height/3-15 && mousey()< window_height/3 + 15)
- {
- play_Menu();
- draw_Main_Menu();
- }
- if(mousex()> window_lenght/2-115 && mousex()<window_lenght/2+115)
- if(mousey()> window_height/3+45 && mousey()< window_height/3 + 75)
- {instructions_Page();
- draw_Main_Menu();}
- if(mousex()> window_lenght/2 - 45 && mousex()<window_lenght/2 +45)
- if(mousey()>window_height/3 + 105 && mousey()<window_height/3+135)
- { selectedOption=TRUE; }
- }
- }
- int main()
- {
- initwindow(window_lenght, window_height, "Bridg-it");
- main_Menu();
- closegraph();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement