c语言扫雷舰源代码使用shape函数,可以用鼠标玩。

看看这个!

# include & ltgraphics.h & gt

# include & ltstdlib.h & gt

# include & ltdos.h & gt

#define LEFTPRESS 0xff01

#定义左键单击0xff10

#定义左拖动0xff19

#定义鼠标移动0xff08

整数[10][10];/*范围*/

int p[10][10];/*数雷之阵*/

int循环;/*回来的迹象*/

int又= 0;/*是否重新开始的变量*/

int scorenum/*开始的时候,数了几个地雷*/

char score[3];/*出口了多少地雷*/

int Keystate

int MouseExist

int MouseButton

int MouseX

int MouseY

/*鼠标光标形状的定义*/

typedef结构

{

无符号整型[32];

char hotx

char hoty

}形状;

/*箭头类型*/

形状箭头={

{

0x3fff,0x1fff,0x0fff,0x07ff,

0x03ff、0x01ff、0x00ff、0x007f、

0x003f、0x00ff、0x01ff、0x10ff、

0x30ff、0xf87f、0xf87f、0xfc3f、

0x0000,0x7c00,0x6000,0x7000,

0x7800,0x7c00,0x7e00,0x7f00,

0x7f80,0x7e00,0x7c00,0x4600,

0x0600,0x0300,0x0300,0x0180

},

0,0,

};

/*鼠标光标显示*/

void MouseOn()

{

_ AX = 0x 01;

gen interrupt(0x 33);

}

/*鼠标光标屏蔽*/

Void MouseOff()/*鼠标光标隐藏*/

{

_ AX = 0x02

gen interrupt(0x 33);

}

Void MouseSetXY(int x,int y)/*设置当前位置*/

{

_ CX = x;

_ DX = y;

_ AX = 0x04

gen interrupt(0x 33);

}

Int LeftPress()/*左键单击*/

{

_ AX = 0x03

gen interrupt(0x 33);

回归(_ BX & amp;1);

}

Voidmousetxy ()/*获取当前位置*/

{

_ AX = 0x03

gen interrupt(0x 33);

MouseX = _ CX;

MouseY = _ DX

}

Begain()/*游戏开始屏幕*/

{

int i,j;

loop:clear device();

MouseOn();

MouseSetXY(180,30);

MouseX = 180;

MouseY = 30

score num = 0;

setfillstyle(SOLID_FILL,7);

吧(190,60,390,290);

setfillstyle(SOLID_FILL,8);

for(I = 100;我& lt300;I+=20)/*画一个网格*/

for(j = 200;j & lt400;j+=20)

杠(j-8,i+8,j+8,I-8);

set color(7);

setfillstyle(SOLID_FILL,黄色);/*画一张脸*/

filllellipse(290,75,10,10);

setcolor(黄色);

setfillstyle(SOLID_FILL,0);

filllellipse(285,75,2,2);

filllellipse(295,75,2,2);

set color(0);

bar(287,80,293,81);

randomize();

for(I = 0;我& lt10;i++)

for(j = 0;j & lt10;j++)

{

num[I][j]= random(7)+10;/*用10代表地雷*/

if(num[i][j]==10)

score num++;

}

sprintf(分数,“%d”,score num);

set color(1);

settextstyle(0,0,2);

outtextxy(210,70,分数);

score num = 100-score num;/*以便以后评判胜负*/

}

Gameove()/*游戏结束画面*/

{

int i,j;

set color(0);

for(I = 0;我& lt10;i++)

for(j = 0;j & lt10;j++)

If(num[i][j]==10)/*如果是地雷,则显示*/

{

setfillstyle(SOLID_FILL,红色);

bar(200+j*20-8,100+i*20-8,200+j*20+8,100+I * 20+8);

setfillstyle(SOLID_FILL,0);

filllellipse(200+j * 20,100+i*20,7,7);

}

}

Int同济(int i,int j)/*有几个雷*/

{

int x = 0;/*10代表我的*/

if(I = = 0 & amp;& ampj==0)

{

if(num[0][1]==10)

x++;

if(num[1][0]==10)

x++;

if(num[1][1]= = 10)

x++;

}

else if(I = = 0 & amp;& ampj==9)

{

if(num[0][8]==10)

x++;

if(num[1][9]==10)

x++;

if(num[1][8]==10)

x++;

}

else if(I = = 9 & amp;& ampj==0)

{

if(num[8][0]==10)

x++;

if(num[9][1]==10)

x++;

if(num[8][1]==10)

x++;

}

else if(I = = 9 & amp;& ampj==9)

{

if(num[9][8]==10)

x++;

if(num[8][9]==10)