#include<dos.h>
#include<graphics.h>
#include<bios.h>
#include<stdlib.h>
#include<stdio.h>
#include<math.h>
#include<alloc.h>
#define false 0
#define ture 1
#define ESC 27
#define SPACE 32
#define jia 43
#define jian 45
int mouse_installed=false;
void *circ_h=NULL;
void *circ_b=NULL;
void *circ_c=NULL;
void *rect_b=NULL;
struct cir_arr{
int left,top,right,bottom;
}circle_arr[7];
int bar_bar[6][4]={30 , 65 , 50 , 85 , 60 , 65 , 80 , 85 , 90 ,65 , 110 ,
85 ,120 , 65 , 140 , 85 ,150 , 65 , 170 , 85 , 180 , 65 , 200 , 85 };
int InitMouse()
{
union REGS r;
r.x.ax=0;
int86(0x33,&r,&r);
if(r.x.ax==0xffff)
mouse_installed=ture;
else
mouse_installed=false;
return(r.x.bx);
}
int ShowMouse()
{
union REGS r;
if(mouse_installed==false)
return (-1);
r.x.ax=0x0001;
int86(0x33,&r,&r);
return(0);
}
int HideMouse()
{
union REGS r;
if(mouse_installed==false)
return (-1);
r.x.ax=0x0002;
int86(0x33,&r,&r);
return(0);
}
int GetMouseXY(int *x,int *y)
{
union REGS r;
if(mouse_installed==false)
return (-1);
r.x.ax=0x0003;
int86(0x33,&r,&r);
*x=r.x.cx;
*y=r.x.dx;
return(0);
}
int SetMouseXY(int x,int y)
{
union REGS r;
if(mouse_installed==false)
return (-1);
r.x.ax=0x0004;
r.x.cx=x;
r.x.dx=y;
int86(0x33,&r,&r);
return(0);
}
int GetPressInfo(int button)
{
union REGS r;
if(mouse_installed==false)
return (-1);
r.x.ax=0x0005;
r.x.bx=button;
int86(0x33,&r,&r);
return(r.x.bx);
}
int GetReleaseInfo(int button)
{
union REGS r;
if(mouse_installed==false)
return (-1);
r.x.ax=0x0006;
r.x.bx=button;
int86(0x33,&r,&r);
return(r.x.bx);
}
int SetXRange(int min,int max)
{
union REGS r;
if(mouse_installed==false)
return (-1);
r.x.ax=0x0007;
r.x.cx=min;
r.x.dx=max;
int86(0x33,&r,&r);
return(0);
}
int SetYRange(int min,int max)
{
union REGS r;
if(mouse_installed==false)
return (-1);
r.x.ax=0x0008;
r.x.cx=min;
r.x.dx=max;
int86(0x33,&r,&r);
return(0);
}
main()
{
int dr=DETECT;
char off_[]="off";
char *on_off=off_;
int mode;
int mouse_buttons;
int i,j;
int i_piece,j_piece;
unsigned size1;
unsigned size2;
unsigned size3;
char key=0;
int x=0,y=0;
int start=false;
int speed=7,speed_show=1;
int count_time=0;
int x0,y0;
int x1,x2,x3,x4,x5,x6,y1,y2,y3,y4,y5,y6;
int dx0=10,dx1=10,dx2=10,dx3=10,dx4=10,dx5=10,dx6=10;
int dy0=10,dy1=10,dy2=10,dy3=10,dy4=10,dy5=10,dy6=10;
unsigned count=000000;
int achievement=0;
int achi;
int left0=ture,up0=false,down0=false,right0=false;
int left1=false,up1=ture,down1=false,right1=ture;
int left2=ture,up2=ture,down2=false,right2=false;
int left3=false,up3=false,down3=ture,right3=false;
int left4=ture,up4=false,down4=false,right4=ture;
int left5=false,up5=false,down5=ture,right5=ture;
int left6=ture,up6=ture,down6=ture,right6=false;
mouse_buttons=InitMouse();
initgraph(&dr,&mode,"");
if(mouse_installed==false)
{
printf("Mouse NOT installed!\n");
printf("Program finished!\n");
exit(-1);
}
setbkcolor(5);
ShowMouse();
setcolor(YELLOW);
outtextxy(10,13,"Please press space or kit mouse'cen-");
outtextxy(10,25,"ter button start the game !");
outtextxy(10,37,"You can press ESC or kit mouse' right");
outtextxy(10,49,"button to QUIT !");
line(305,10,305,60);
line(430,10,430,60);
line(0,60,639,60);
rectangle(15,90,625,455);
rectangle(0,10,639,470);
rectangle(55,150,90,180);
rectangle(505,150,540,180);
rectangle(355,355,390,385);
rectangle(85,350,120,380);
rectangle(320,210,355,240);
rectangle(118,250,153,280);
rectangle(390,236,425,266);
size1=imagesize(55,150,90,180);
if(size1!=1)
rect_b=malloc(size1);
getimage(55,150,90,180,rect_b);
setfillstyle(SOLID_FILL,WHITE);
outtextxy(547,267,"*");
circle(550,270,5);
x0=543;y0=264;
outtextxy(197,267,"1");
circle(200,270,5);
x1=193;y1=264;
outtextxy(185,260,"2");
circle(188,263,5);
x2=181;y2=257;
outtextxy(185,274,"3");
circle(188,277,5);
x3=181;y3=271;
outtextxy(173,253,"4");
circle(176,256,5);
x4=169;y4=250;
outtextxy(173,267,"5");
circle(176,270,5);
x5=169;y5=264;
outtextxy(173,281,"6");
circle(176,284,5);
x6=169;y6=278;
circle(276,270,5);
size1=imagesize(543,264,556,275);
size2=imagesize(542,263,557,276);
size3=imagesize(269,264,282,275);
if(size1!=1)
circ_h=malloc(size1);
if(size2!=1)
circ_b=malloc(size2);
if(size3!=1)
circ_c=malloc(size3);
getimage(543,264,556,275,circ_h);
getimage(442,263,457,276,circ_b);
getimage(269,264,282,275,circ_c);
putimage(269,264,circ_c,XOR_PUT);
circle_arr[0].left=x0;circle_arr[0].top=y0;
circle_arr[0].right=x0+13;circle_arr[0].bottom=y0+13;
circle_arr[1].left=x1;circle_arr[1].top=y1;
circle_arr[1].right=x1+13;circle_arr[1].bottom=y1+13;
circle_arr[2].left=x2;circle_arr[2].top=y2;
circle_arr[2].right=x2+13;circle_arr[2].bottom=y2+13;
circle_arr[3].left=x3;circle_arr[3].top=y3;
circle_arr[3].right=x3+13;circle_arr[3].bottom=y3+13;
circle_arr[4].left=x4;circle_arr[4].top=y4;
circle_arr[4].right=x4+13;circle_arr[4].bottom=y4+13;
circle_arr[5].left=x5;circle_arr[5].top=y5;
circle_arr[5].right=x5+13;circle_arr[5].bottom=y5+13;
circle_arr[6].left=x6;circle_arr[6].top=y6;
circle_arr[6].right=x6+13;circle_arr[6].bottom=y6+13;
setfillstyle(1,3);
for(count=0;count<76;count+=15)
{
bar(30+count*2,65,50+count*2,85);
outtextxy(30+count*2+7,65+6,"*");
}
while(key!=ESC)
{
delay(speed*1000);
if(kbhit())
key=getch();
if(key==SPACE)
{
start=ture;
on_off="on ";
achi=false;
key=0;
achievement=0;
}
for(count=0;count<6;count++)
{
if(x>bar_bar[count][0]&&y>bar_bar[count][1]&&x<bar_bar[count][2]&&y<bar_bar[count][3]&&key==jia)
{
key=0;
gotoxy(50,6);
switch(count)
{
case 0:if(dx0>=15) dx0=10;else dx0++;break;
case 1:if(dx1>=15) dx1=10;else dx1++;break;
case 2:if(dx2>=15) dx2=10;else dx2++;break;
case 3:if(dx3>=15) dx3=10;else dx3++;break;
case 4:if(dx4>=15) dx4=10;else dx4++;break;
case 5:if(dx5>=15) dx5=10;else dx5++;break;
case 6:if(dx6>=15) dx6=10;else dx6++;break;
}
}
if(x>bar_bar[count][0]&&y>bar_bar[count][1]&&x<bar_bar[count][2]&&y<bar_bar[count][3]&&key==jian)
{
key=0;
switch(count)
{
case 0:if(dx0<=5) dx0=10;else dx0--;break;
case 1:if(dx1<=5) dx1=10;else dx1--;break;
case 2:if(dx2<=5) dx2=10;else dx2--;break;
case 3:if(dx3<=5) dx3=10;else dx3--;break;
case 4:if(dx4<=5) dx4=10;else dx4--;break;
case 5:if(dx5<=5) dx5=10;else dx5--;break;
case 6:if(dx6<=5) dx6=10;else dx6--;break;
}
}
}
if(GetPressInfo(0)==1)
{
speed--;
if(speed<0)
speed=7;
start=ture;
on_off="on ";
achi=false;
achievement=0;
}
if(GetPressInfo(1)==1)
{
/*return;*/start=false;
on_off="off";
achi=ture;
achievement=0;
}
if(GetPressInfo(mouse_buttons-1)==1)
{
start=ture;
on_off="on ";
achi=false;
achievement=0;
}
if(GetReleaseInfo(0)==1)
{
}
if(GetReleaseInfo(mouse_buttons-1)==1)
{
}
putimage(55,150,rect_b,COPY_PUT);
putimage(505,150,rect_b,COPY_PUT);
putimage(355,355,rect_b,COPY_PUT);
putimage(85,350,rect_b,COPY_PUT);
putimage(320,210,rect_b,COPY_PUT);
putimage(118,250,rect_b,COPY_PUT);
putimage(390,236,rect_b,COPY_PUT);
if(circle_arr[0].left<54)
{
left0=false;right0=ture;
}
if(circle_arr[0].right>584)
{
left0=ture;right0=false;
}
if(circle_arr[0].top<126)
{
down0=ture;up0=false;
}
if(circle_arr[0].bottom>420)
{
down0=false;up0=ture;
}
circle_arr[0].left=x0;circle_arr[0].top=y0;
circle_arr[0].ri