
#include<iostream.h>
#include<conio.h>
#include<graphics.h>
#include<dos.h>
#include<stdlib.h>


class mouse
{
 union REGS i,o;
  public:
 int initmouse(void);
 void showmouseptr(void);
 void hidemouseptr(void);
 void restrictmouseptr(int,int,int,int);
 void getmousepos(int*,int*,int*);
 void leftmousepos(int*,int*);
 void moveto(int,int);
};

void main()
{
 int gd,gm;
 gd=DETECT;
 initgraph(&gd,&gm,"C:\\tc\\bgi");

 setbkcolor(DARKGRAY);
 setcolor(RED);
 setfillstyle(SOLID_FILL,BLUE);
 rectangle(0,0,getmaxx()-1,getmaxy()-1);

 rectangle(0,15,getmaxx()-1,15);
 floodfill(1,1,RED);
 settextstyle(0,0,0);
 setcolor(WHITE);
 outtextxy(20,3,"Game of soldiers");

 settextstyle(4,0,6);
 outtextxy(50,150,"       JUST           ");
 outtextxy(50,185," Trap enemy soldiers");
 outtextxy(50,235,"         &         ");

 outtextxy(50,285,"        The game.");
 setcolor(GREEN);
 outtextxy(50,285,"   WIN");
 setcolor(CYAN);
 outtextxy(50,35,"GAME OF SOLDIERS");

 setcolor(WHITE);

 for(int i=0;i<3;i++)
 {
  rectangle(90+200*i,400,170+200*i,420);
  rectangle(90-5+200*i,400-5,170+5+200*i,420+5);
 }



 /*
 outtextxy(50,35,"In this game you have to capture the enemy soldiers and if any enemy");
 outtextxy(30,45,"is traped in between your soldiers, it becomes your soldier");
 */

// rectangle(10,10,getmaxx()-11,getmaxy()-11);




 mouse m;


 int a=m.initmouse();

 m.showmouseptr();


 getch();

}




int mouse::initmouse(void)
{
 i.x.ax=0;
 int86(0x33,&i,&o);//-1 for success i.e. drivers available
 return o.x.ax;  // 0 is no driver
}

void mouse::showmouseptr(void)
{
 i.x.ax=1;
 int86(0x33,&i,&o);
}

void mouse::hidemouseptr(void)
{
 i.x.ax=2;
 int86(0x33,&i,&o);
}

void mouse::restrictmouseptr(int x1,int y1,int x2,int y2)
{
 i.x.ax=7;
 i.x.cx=x1;
 i.x.dx=x2;
 int86(0x33,&i,&o);
 i.x.ax=8;
 i.x.cx=y1;
 i.x.dx=y2;
 int86(0x33,&i,&o);
}

void mouse::getmousepos(int *b,int *x,int *y)
{
 i.x.ax=3;
 int86(0x33,&i,&o);
 *b=o.x.bx;
 *x=o.x.cx;
 *y=o.x.dx;
}

void mouse::leftmousepos(int *x,int *y)
{
 do
 {
  i.x.ax=3;
  int86(0x33,&i,&o);
  *x=o.x.cx;
  *y=o.x.dx;
 }while(o.x.bx!=1);
}

void mouse::moveto(int x,int y)
{
 i.x.ax=4;
 i.x.cx=x;
 i.x.dx=y;
 int86(0x33,&i,&o);
}
