| version 1.6, 2003/07/12 12:43:13 |
version 1.7, 2003/07/16 16:59:12 |
|
|
| /* $Platon: games/mines/mines.c,v 1.5 2003/06/27 02:18:31 nepto Exp $ */ |
/* $Platon: games/mines/mines.c,v 1.6 2003/07/12 12:43:13 nepto Exp $ */ |
| |
|
| /* CONSTS */ |
/* CONSTS */ |
| #define EXENAME "mines.exe" |
#define EXENAME "mines.exe" |
| Line 167 BYTE MainMenu(void); |
|
| Line 167 BYTE MainMenu(void); |
|
| int GraphInit(void); |
int GraphInit(void); |
| void SetData(void); |
void SetData(void); |
| void SetMines(); |
void SetMines(); |
| |
void SetExcludeMines(int ex, int ey); |
| void SetSquare(WORD x,WORD y,BYTE status); |
void SetSquare(WORD x,WORD y,BYTE status); |
| void WriteInfo(WORD x,WORD y); |
void WriteInfo(WORD x,WORD y); |
| BYTE DoAll(void); |
BYTE DoAll(void); |
| Line 511 void SetData(void) /* {{{ */ |
|
| Line 512 void SetData(void) /* {{{ */ |
|
| /*----------------------------------------------------------------------*/ |
/*----------------------------------------------------------------------*/ |
| void SetMines() /* {{{ */ |
void SetMines() /* {{{ */ |
| { |
{ |
| |
SetExcludeMines(-1, -1); |
| |
} /* }}} */ |
| |
|
| |
void SetExcludeMines(int ex, int ey) /* {{{ */ |
| |
{ |
| STSQUARE *p; |
STSQUARE *p; |
| int i,x,y,a,b; |
int i, x, y, a, b; |
| |
|
| randomize(); |
randomize(); |
| cmines=getmines(nx,ny,diff); |
cmines = getmines(nx, ny, diff); |
| sqclosed=(nx*ny)-cmines; |
sqclosed = (nx * ny) - cmines; |
| p=psquare; |
p = psquare; |
| for (i=nx*ny;i>0;i--,p++) |
for (i = nx *ny; i >0; i--, p++) |
| p->value = p->sqopen = p->sqpress = p->sqmark=NO; |
p->value = p->sqopen = p->sqpress = p->sqmark = NO; |
| for (i=getmines(nx,ny,diff);i>0;i--) { |
|
| while (value(x=RAND_INT(0, nx - 1),y=RAND_INT(0, ny - 1))==MINE); |
i = getmines(nx, ny, diff); |
| value(x,y)=MINE; |
if (nx * ny - i < 1) |
| |
ex = ey = -1; /* Disable exclusion if no empty field is available */ |
| |
for (i = i; i > 0; i--) { |
| |
do { |
| |
x = RAND_INT(0, nx - 1); |
| |
y = RAND_INT(0, ny - 1); |
| |
} while ((x == ex && y == ey) || value(x, y) == MINE); |
| |
value(x, y) = MINE; |
| } |
} |
| for (x=nx-1;x>=0;x--) { |
for (x=nx-1;x>=0;x--) { |
| for (y=ny-1;y>=0;y--) { |
for (y=ny-1;y>=0;y--) { |
| Line 849 BYTE DoAll(void) /* {{{ */ |
|
| Line 862 BYTE DoAll(void) /* {{{ */ |
|
| if (!but && |
if (!but && |
| !sqopen(x,y) && sqpress(x,y) && sqmark(x,y) != 1) { |
!sqopen(x,y) && sqpress(x,y) && sqmark(x,y) != 1) { |
| if (first_click) { |
if (first_click) { |
| while (value(x, y) != 0) { |
if (value(x, y) == MINE) { |
| SetMines(); |
outtextxy(10, 10, "HERE!"); |
| |
SetExcludeMines(x, y); |
| } |
} |
| first_click = 0; |
first_click = 0; |
| } |
} |