flood-it: fixed bug, optimizations

git-svn-id: svn://kolibrios.org@2283 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Kirill Lipatov (Leency) 2011-10-09 09:24:33 +00:00
parent 571645e609
commit 9d0d075e30

View File

@ -1,4 +1,4 @@
//Leency 06.10.2011, Flood-it! v2.1, GPL
//Leency 06.10.2011, Flood-it! v2.2, GPL
#include "lib\kolibri.h"
#include "lib\random.h"
@ -31,7 +31,7 @@ char *BOARD_SIZES[]={ "S", "L", 0 };
#ifdef LANG_RUS
char *BUTTON_CAPTIONS[]={ " <EFBFBD>®¢ ï [F2]", " <20>®¬®éì [F1]", " ‚ë室 [Esc]", 0};
char *BUTTON_CAPTIONS[]={ " ‡ ­®¢® [F2]", " <20>®¬®éì [F1]", " ‚ë室 [Esc]", 0};
char CLICKS_TEXT[]=" Š«¨ª¨: /";
char LEVELS_TEXT[]="<EFBFBD>®«¥:";
@ -72,9 +72,9 @@ char *BOARD_SIZES[]={ "S", "L", 0 };
#endif
int color_matrix[28*28]; //öâåòà äëÿ ïîëÿ ñ êâàäðàòèêàìè
unsigned char color_matrix[28*28]; //öâåòà äëÿ ïîëÿ ñ êâàäðàòèêàìè
int loose_matrix[14*14]={
unsigned char loose_matrix[14*14]={
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 3, 3, 3, 2, 3, 3, 3, 2, 3, 2, 3, 2, 2,
@ -91,7 +91,7 @@ int loose_matrix[14*14]={
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2
};
int win_matrix[14*14]={
unsigned char win_matrix[14*14]={
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 4, 1, 4,
@ -123,7 +123,11 @@ void main()
IF (id==1) || (id==4) ExitProcess();
IF (id==2) goto _NEW_GAME_MARK;
IF (id==3) goto _HELP_MARK;
IF (id>=100) make_turn(id-100);
IF (id>=100)
{
make_turn(id-100);
break;
}
if (id>=10)
{
id=id-10*3;
@ -240,21 +244,18 @@ void draw_window()
void new_game()
{
int i, j;
int i;
//randomize();
CLICKS = 0;
for (i=0;i<BLOCKS_NUM;i++)
for (j=0;j<BLOCKS_NUM;j++)
color_matrix[i*BLOCKS_NUM+j] = random(6);
for (i=0;i<BLOCKS_NUM*BLOCKS_NUM;i++)
color_matrix[i] = random(6);
}
void fill_field(int new_color_id)
{
int i=0, j=0,
int i, j,
old_color_id=color_matrix[0],
restart;
#define MARKED 6
@ -280,9 +281,8 @@ void fill_field(int new_color_id)
}
IF (restart) goto _RESTART_MARK;
for (i=0;i<BLOCKS_NUM;i++)
for (j=0;j<BLOCKS_NUM;j++)
IF (color_matrix[i*BLOCKS_NUM+j]==MARKED) color_matrix[i*BLOCKS_NUM+j]=new_color_id;
for (i=0;i<BLOCKS_NUM*BLOCKS_NUM;i++)
IF (color_matrix[i]==MARKED) color_matrix[i]=new_color_id;
}
@ -294,9 +294,8 @@ int check_for_end()
{
IF (CLICKS==MAX_CLICKS) //âûèãðûøü íà ïîñëåäíåì õîäå
{
for (i=0;i<BLOCKS_NUM;i++) //ïðîâåðÿåì âñ¸ ëè ïîëå îäíîãî öâåòà, åñëè íåò óõîäèì
for (j=0;j<BLOCKS_NUM;j++)
IF (color_matrix[i*BLOCKS_NUM+j]<>color_matrix[0]) goto _LOOSE_MARK;
for (i=0;i<BLOCKS_NUM*BLOCKS_NUM;i++) //ïðîâåðÿåì âñ¸ ëè ïîëå îäíîãî öâåòà, åñëè íåò óõîäèì
IF (color_matrix[i]<>color_matrix[0]) goto _LOOSE_MARK;
goto _WIN_MARK;
}
@ -326,9 +325,8 @@ int check_for_end()
return 1;
}
for (i=0;i<BLOCKS_NUM;i++) //ïðîâåðÿåì âñ¸ ëè ïîëå îäíîãî öâåòà, åñëè íåò óõîäèì
for (j=0;j<BLOCKS_NUM;j++)
IF (color_matrix[i*BLOCKS_NUM+j]<>color_matrix[0]) return 0;
for (i=0;i<BLOCKS_NUM*BLOCKS_NUM;i++) //ïðîâåðÿåì âñ¸ ëè ïîëå îäíîãî öâåòà, åñëè íåò óõîäèì
IF (color_matrix[i]<>color_matrix[0]) return 0;
//âñ¸ ïîëå îäíîãî öâåòà è ôèøåê ìåíüøå MAX_CLICKS -> ïîáåäà