C:\John\mines.cpp(5) :fatal error C1083: Cannot open include file: 'graphics.h': No such file or directory


from this code

#include<conio.h>
#include<stdio.h>
#include <graphics.h>
#include<stdlib.h>
#include<dos.h>
#include<time.h>
#include "events.h"
#define YES -1
#define NO 0
#define MARK 1
#define DOUBT 2

int boxleft=225,minemarked=0,explode = NO,totalmine = 25;
void minegenerate(int num,int x, int y);
void reinitialise();
int open_z(int x, int y);
int checkopen();
int checkcount(int x,int y);
void showwin()
{setcolor(YELLOW);outtextxy(250,140,"COOL U WIN !!!");
 explode = YES;// to freeze opening
}
void showdead();

void showcount()
{
char temp[4];
setfillstyle(1,BLACK);
floodfill(305,105,BLUE);
itoa(totalmine-minemarked,temp,10);
setcolor(RED);
outtextxy(305,105,temp);
/*
rectangle(550,100,600,130);
floodfill(555,105,RED);
itoa(boxleft,temp,10);
setcolor(BLUE);
outtextxy(555,105,temp);
*/
}

//void openbox(mine here);

class mine : public CmdBtn
{

public:
 friend  void openbox(int a, int b);
// friend void reinitialise();
 int xpos,ypos;
 int ismine;
 int isopen;
 mine(void);
 mine(int _left,int _top,int _right,int _bottom,char far* _Caption="",int FC = TXT_CLR,int BC = BTN_FACE,int Flags = ABS_COORDS);
 ~mine();

void OnMouseDown(int Button,int x,int y,int shift);
void OnMouseUp(int Button,int x,int y,int shift);
void virtual MsgProcessor(UINT msg,int info1,int info2,int info3,int info4);

};

mine::mine(void)
{
SetData(0,0,0,0);
Fout=MSdown=0;
isopen = NO;
AddElement(this);
}

mine::mine(int _left,int _top,int _right,int _bottom,char far* _Caption,int FC,int BC,int Flags)
{
SetData(_left,_top,_right,_bottom,_Caption,FC,BC,Flags);
Fout = MSdown=0;
isopen = NO;
AddElement(this);

}

mine::~mine()
 {
 RemoveElement(this);
 }

void mine::OnMouseDown(int Button,int x,int y,int shift)
{
MSdown=1;
//printf("y");
if(explode == NO)
{
switch(Button)
{

	case LT_BTN:

	if( isopen == YES)//equ to double click winmine
	{
	if( ismine == checkcount(xpos,ypos) )
	{open_z(xpos, ypos) ;
	if(explode == YES) {showdead(); }
	}
	break;
	}

	if( isopen == NO )
	{
	Draw3D(_3D_INSET);
	isopen = YES;
	boxleft--;
	//printf(".");
	break;
	}

	break;

	case RT_BTN:

	 if(isopen == DOUBT)
	 {
	 isopen = NO;
	 minemarked--;
	 showcount();
	 break;
	 }
	 if(isopen == NO)
	 { minemarked++;
	   showcount();
	   isopen = MARK;
	  break;
	  }
	if(isopen == MARK )
	{
	isopen = DOUBT;
	break;
	}
   }//end of switch case
 }// end of if
}

void mine::OnMouseUp(int Button,int x,int y,int shift)
{
 if(MSdown == 1 && explode == NO)
  {
//	printf("x");
	MSdown = 0;
	if(boxleft == totalmine) { showwin(); }
    switch(Button)
    {
	case LT_BTN:
	if (isopen == YES) ; else break;
	if(ismine != YES)
	{itoa(ismine,Caption,10);
	BackColor = GREEN;
	Draw3D(_2D_FLAT);
	}
	if(ismine == 0 )
		{//open_z(xpos,ypos);
		while(1)
		 {
		  if(checkopen() == 0) break;
		  }
		 }
	if(ismine == YES)
	{
	showdead();
	break;
	}
	break;

	case RT_BTN:

	if( isopen == NO)
	{
	BackColor = BLUE;
	*Caption = '\0';
	Draw3D(_3D_RAISED);
	break;
	}
	if( isopen == MARK)
	{
	strcpy(Caption,"*");
	BackColor = RED;
	Draw3D(_3D_RAISED);
	break;
	}
	if( isopen == DOUBT)
	{
	strcpy(Caption,"?");
	BackColor = RED;
	Draw3D(_3D_RAISED);
	break;
	}
    } //end of switch case
  }
}

void mine::MsgProcessor(UINT msg,int info1,int info2,int info3,int info4)
{
 int vRet = 1;
 if(ptrSpecificMsg != 0)
 vRet = (*ptrSpecificMsg)(msg,info1,info2,info3,info4);
 if(vRet)
 {
 switch(msg)
 {
// case KM_KEYPRESS: OnKeyPress(info1,info2,info3);break;

 case MM_MSDOWN : OnMouseDown(info1,info2,info3,info4);break;

// case MM_MSMOVE : OnMouseMove(info1,info2,info3,info4);break;

 case MM_MSUP: OnMouseUp(info1,info2,info3,info4);break;

// case SM_FOUT : OnFocusOut(info1);break;

// case SM_FIN : OnFocusIn(info1);break;

 }
 }
 return;
}


mine square[15][15];
//mine* mnptr;


CmdBtn btnExit(500,55,35,15,"EXIT",RED,BTN_FACE,REL_COORDS);
int OnbtnExit(UINT msg,int info1,int info2,int info3,int info4);

CmdBtn btnRefresh(360,55,85,15,"NEW GAME",RED,BTN_FACE,REL_COORDS);
int OnbtnRefresh(UINT msg,int info1,int info2,int info3,int info4);

CmdBtn nup,ndown;

int Onnup(UINT msg,int info1,int info2,int info3,int info4);
int Onndown(UINT msg,int info1,int info2,int info3,int info4);

void Initialise();
void DrawElements();
void InitApp();

void main()
{
Initialise();
InitApp();
DrawElements();
showmsptr();
//mnptr = square;
minegenerate(totalmine,15,15);
showcount();
BeginEvents();
closegraph();
}

void Initialise()
{
int gd=0,gm;
initgraph(&gd,&gm,"f:\\tc-300\\bgi");
settextstyle(3, HORIZ_DIR,3);
setcolor(YELLOW);
outtextxy(200,20,"SUBS  MINESWEEPER");
settextstyle(0,HORIZ_DIR,0);
setcolor(RED);
outtextxy(200,105,"MINE LEFT");
setcolor(BLUE);
rectangle(300,100,325,125);
setcolor(LIGHTGRAY);
rectangle(120,130,475,470);   //canvas
initmouse();
showmsptr();
//delay(1000);
hidemsptr();
}

void InitApp()
{
int i,j;
for(i=0;i<15;i++)
{
for(j=0;j<15;j++)
 {
  square[i][j].SetData(150+20*j,150+20*i,150+20*(j+1)-2,150+20*(i+1)-2,"",YELLOW,BLUE);
  square[i][j].ismine = 0;
  square[i][j].xpos = i;
  square[i][j].ypos = j;
    }
  }
  btnExit.setMsgProcessor(&OnbtnExit);
  btnRefresh.setMsgProcessor(&OnbtnRefresh);

setcolor(GREEN);
outtextxy(150,70,"SELECT TOTAL MINE");
nup.SetData(300,60,20,12,"/\\",4,7,REL_COORDS);
nup.Draw3D(_3D_RAISED);
nup.setMsgProcessor(&Onnup);

ndown.SetData(300,76,20,12,"\\/",4,7,REL_COORDS);
ndown.Draw3D(_3D_RAISED);
ndown.setMsgProcessor(&Onndown);

}

void DrawElements()
{
int i,j;
hidemsptr();
for(i=0;i<15;i++)
{
for(j=0;j<15;j++)
{
square[i][j].Draw3D(_3D_RAISED);
}
}
btnExit.Draw3D(_3D_RAISED);
btnRefresh.Draw3D(_3D_RAISED);
showmsptr();
}

int OnbtnExit(UINT msg,int info1,int info2,int info3,int info4)
{
switch(msg)
{
case KM_KEYPRESS:
if(info1==' ')DO_MSG_DESPATCHING = 0;
break;
case MM_MSUP: DO_MSG_DESPATCHING = 0;
break;
}
return DODEF;
}

int OnbtnRefresh(UINT msg,int info1,int info2,int info3,int info4)
{
switch(msg)
{
case MM_MSUP: reinitialise();
}
return DODEF;
}


int Onnup(UINT msg,int info1,int info2,int info3,int info4)
{
switch(msg)
{
case MM_MSUP:
	 hidemsptr();
	 if(totalmine < 80)
	 {
	 totalmine++;
	 reinitialise();
	 }
	 showmsptr();
	 return DODEF;
}
}

int Onndown(UINT msg,int info1,int info2,int info3,int info4)
{
switch(msg)
{
case MM_MSUP:
	 hidemsptr();
	 if(totalmine>10)
	 {
	 totalmine--;
	 reinitialise();
		  }
	 showmsptr();

return DODEF;
}
}


void minegenerate(int num,int x, int y)
{
int i,j,k,l;
randomize();
for(i=0;i<num;)
{
// randomize();
 j = rand() % (x*y);
// printf(" %d ",j);
 k =  j / x;
 l = j % x;
 if( square[k][l].ismine == NO )
 {   square[k][l].ismine = YES;
   i++;
   }
}

// number assign
int count;
for(i=0;i<x;i++)
for(j=0;j<y;j++)
{
	count = 0;
	if(square[i][j].ismine != YES)//assign number
	{
	if(i != 0 && square[i-1][j].ismine ==YES) count++;
	if(i != x-1 && square[i+1][j].ismine == YES) count++;
	if(j != 0 && square[i][j-1].ismine == YES) count++;
	if(j != y-1 && square[i][j+1].ismine == YES) count++;

	if(i != 0 && j != 0 && square[i-1][j-1].ismine ==YES) count++;
	if(i != x-1 && j != y-1 && square[i+1][j+1].ismine == YES) count++;
	if(i != x-1 && j != 0 && square[i+1][j-1].ismine == YES) count++;
	if(i != 0 && j != y-1 && square[i-1][j+1].ismine == YES) count++;

	square[i][j].ismine = count;
	}
   }

}

int checkcount( int i,int j)
{
int count = 0;

if(i != 0 && square[i-1][j].isopen == MARK) count++;
if(i != 14 && square[i+1][j].isopen == MARK) count++;
if(j != 0 && square[i][j-1].isopen == MARK) count++;
if(j != 14 && square[i][j+1].isopen == MARK) count++;

if(i != 0 && j != 0 && square[i-1][j-1].isopen == MARK) count++;
if(i != 14 && j != 14 && square[i+1][j+1].isopen == MARK) count++;
if(i != 14 && j != 0 && square[i+1][j-1].isopen == MARK) count++;
if(i != 0 && j != 14 && square[i-1][j+1].isopen == MARK) count++;
return(count);
}

int open_z(int i, int j)
{

//int i,j,k,l;
int opened = 0;
	if(i != 0 && square[i-1][j].isopen == NO)
       {
	openbox(i-1,j); opened++;
       //	if(square[i-1][j].ismine == 0) open_z(i-1,j);
	}

	if(i != 14 && square[i+1][j].isopen == NO)
	{
	openbox(i+1,j);opened++;
	//if(square[i+1][j].ismine == 0) open_z(i+1,j);
	}

	if(j != 0 && square[i][j-1].isopen == NO)
	{
	openbox(i,j-1);opened++;
	//if(square[i][j-1].ismine == 0) open_z(i,j-1);
	}

	if(j != 14 &&  square[i][j+1].isopen == NO)
	{
	openbox(i,j+1);opened++;
	//if(square[i][j+1].ismine == 0) open_z(i,j+1);
	}

	if(i != 0 && j != 0  && square[i-1][j-1].isopen == NO)
	{
	openbox(i-1,j-1);opened++;
	//if(square[i-1][j-1].ismine == 0) open_z(i-1,j-1);
	}

	if(i != 14 && j != 0 &&  square[i+1][j-1].isopen == NO)
	{
	openbox(i+1,j-1);opened++;
	//if(square[i+1][j+1].ismine == 0) open_z(i+1,j+1);
	}

	if(i != 0 && j != 14  && square[i-1][j+1].isopen == NO)
	{
	 openbox(i-1,j+1);opened++;
	 //if(square[i+1][j-1].ismine == 0) open_z(i+1,j-1);
	 }

	if(j != 14 && i != 14 &&  square[i+1][j+1].isopen == NO)
	{openbox(i+1,j+1);opened++;
	//if(square[i+1][j-1].ismine == 0) open_z(i+1,j-1);
	}

 return opened;
}

int checkopen()
{
int noofopenup=0;
int i,j;
for(i=0;i<15;i++)
for(j=0;j<15;j++)
{
if(square[i][j].isopen == YES && square[i][j].ismine == 0)
noofopenup += open_z(i,j);
}
return noofopenup;
}


void openbox(int a, int b)
{
if(square[a][b].ismine == YES)
{strcpy(square[a][b].Caption,"*");
 square[a][b].BackColor = RED;
 explode = YES;
 }
else
{itoa(square[a][b].ismine,square[a][b].Caption,10);
square[a][b].BackColor = GREEN;}
square[a][b].isopen = YES;
boxleft--;
//printf(".");
hidemsptr();
square[a][b].Draw3D(_2D_FLAT);
showmsptr();
}

void showdead()
{
int i,j;
for(i=0;i<15;i++)
for(j=0;j<15;j++)
openbox(i,j);
outtextxy(250,140,"OOPS UR DEAD");
//getch();
//reinitialise();
}

void reinitialise()
{
int i,j;
hidemsptr();
setfillstyle(1,BLACK);
floodfill(130,135,LIGHTGRAY);
//setcolor(BLACK);
//bar(121,131,474,469);   //canvas
//getch();
for(i=0;i<15;i++)
for(j=0;j<15;j++)
{
  square[i][j].SetData(150+20*j,150+20*i,150+20*(j+1)-2,150+20*(i+1)-2,"",YELLOW,BLUE);
  //square[i][j].Caption = '\0';
  square[i][j].ismine = 0;
  square[i][j].isopen = NO;
  square[i][j].xpos = i;
  square[i][j].ypos = j;
  square[i][j].Draw3D(_3D_RAISED);
//  square[i][j].Fout=square[i][j].MSdown=0;
 }
explode = NO;
minemarked = 0;
boxleft = 225;
minegenerate(totalmine,15,15);
//DrawElements();
showcount();
showmsptr();

}

you are using the wrong compiler. Get ancient TurboC or Turbo C++ and it will probably compile.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.