mirror of
https://github.com/KolibriOS/kolibrios.git
synced 2025-08-03 19:56:31 -04:00
Floot-It v3.0 (#181)
- adopt window size to screen size - bigger fonts - proper colored 'S' and 'L' buttons - fix issue: after won the game clicks count always increased to max - code refactoring, translate comments to English - help updated Reviewed-on: https://git.kolibrios.org/KolibriOS/kolibrios/pulls/181 Reviewed-by: Max Logaev <maxlogaev@proton.me> Co-authored-by: leency <lipatov.kiril@gmail.com> Co-committed-by: leency <lipatov.kiril@gmail.com>
This commit is contained in:
parent
58e2d0b844
commit
81dafb3025
5
programs/games/flood-it/build.bat
Normal file
5
programs/games/flood-it/build.bat
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
@del *.
|
||||||
|
@For /R %%i In (*.c) Do c-- "%%i"
|
||||||
|
@rename *.com *.
|
||||||
|
@pause
|
||||||
|
@del warning.txt
|
@ -1,9 +0,0 @@
|
|||||||
@del lang.h--
|
|
||||||
@echo #define LANG_ENG 1 >lang.h--
|
|
||||||
C-- flood-it.c
|
|
||||||
@del flood-it
|
|
||||||
@rename flood-it.com flood-it
|
|
||||||
@kpack flood-it
|
|
||||||
@del lang.h--
|
|
||||||
@del warning.txt
|
|
||||||
@pause
|
|
@ -1,9 +0,0 @@
|
|||||||
@del lang.h--
|
|
||||||
@echo #define LANG_RUS 1 >lang.h--
|
|
||||||
C-- flood-it.c
|
|
||||||
@del flood-it
|
|
||||||
@rename flood-it.com flood-it
|
|
||||||
@kpack flood-it
|
|
||||||
@del lang.h--
|
|
||||||
@del warning.txt
|
|
||||||
@pause
|
|
@ -1,49 +1,44 @@
|
|||||||
//Leency 06.10.2011, Flood-it! v2.41, GPL
|
// SPDX-License-Identifier: GPL-2.0-only
|
||||||
|
// Flood-it! - Strategy game: Flood the board with one color, within a step limit.
|
||||||
|
// Copyright (C) 2011-2025 Leency <lipatov.kiril@gmail.com>
|
||||||
|
|
||||||
#include "lib\kolibri.h"
|
#include "lib\kolibri.h"
|
||||||
#include "lib\random.h"
|
#include "lib\random.h"
|
||||||
|
|
||||||
#ifndef AUTOBUILD
|
|
||||||
#include "lang.h--"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
system_colors sc;
|
system_colors sc;
|
||||||
proc_info Form;
|
proc_info Form;
|
||||||
dword stak[100]; //îêíî ïîìîùè
|
dword help_window_stak[100];
|
||||||
|
|
||||||
//óðîâíè ñëîæíîñòè
|
#define DEFAULT_BLOCK_COUNT 14
|
||||||
int DIFFICULTY_LEV_PARAMS[]={ 28, 14, 25, //ëåãêî
|
#define DEFAULT_MAX_CLICKS 25
|
||||||
17, 28, 50}; //òÿæåëî
|
#define MAX_BLOCK_SIZE 28
|
||||||
|
char board_size = -1;
|
||||||
//ïî-óìîë÷àíèþ "ëåãêî"
|
int BLOCK_SIZE; //cell size
|
||||||
int BLOCK_SIZE = 28; //ðàçìåð êâàäðàòèêà
|
int BLOCKS_NUM; //number of cells by X and Y
|
||||||
int BLOCKS_NUM = 14; //êîëè÷åñòâî êâàäðàòèêîâ ïî Õ è ïî Y
|
int MAX_CLICKS; //max clicks for win
|
||||||
int MAX_CLICKS = 25; //ìàêñèìàëüíîå êîëè÷åñòâî êëèêîâ äî âûèãðûøà
|
int CLICKS; //how many clicks user already did
|
||||||
|
int game_end;
|
||||||
|
|
||||||
int CLICKS = 0; //ñêîëüêî õîäîâ óæå ñäåëàë èãðîê
|
#define USER_PANEL_WIDTH 144
|
||||||
|
|
||||||
#define USER_PANEL_WIDTH 119
|
//six colors are used in a game for a cells
|
||||||
|
//and seventh color is used to mark a cell during filling process
|
||||||
//øåñòü öâåòîâ èñïîëüçóåòñÿ â èãðå äëÿ êâàäðàòèêîâ, ñåäüìîé æå (ïîñëåäíèé) äëÿ òîãî,
|
dword FIELD_COLORS[] = {0xf18db6, 0x605ca8, 0xfddc80, 0xdc4a20, 0x46b1e2, 0x7e9d1e, 0x232323};
|
||||||
//÷òîáû îòìåòèòü êâàäðàòèêè â ïðîöåññå çàëèâêè
|
char BOARD_SIZES[] = "S\0L";
|
||||||
dword FIELD_COLORS[]= {0xf18db6, 0x605ca8, 0xfddc80, 0xdc4a20, 0x46b1e2, 0x7e9d1e, 0x232323, 0};
|
|
||||||
char *BOARD_SIZES[]={ "S", "L", 0 };
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef LANG_RUS
|
#ifdef LANG_RUS
|
||||||
char *BUTTON_CAPTIONS[]={ " ‡ ®¢® [F2]", " <20>®¬®éì [F1]", " ‚ë室 [Esc]", 0};
|
char *BUTTON_CAPTIONS[]={ " ‡ ®¢® [F2]", " <20>®¬®éì [F1]", " ‚ë室 [Esc]", 0};
|
||||||
char CLICKS_TEXT[]=" Š«¨ª¨: /";
|
char CLICKS_TEXT[]="Š«¨ª®¢: /";
|
||||||
char LEVELS_TEXT[]="<EFBFBD>®«¥:";
|
char LEVELS_TEXT[]=" <EFBFBD>®«¥:";
|
||||||
|
|
||||||
char HELP_WINDOW_CAPTION[]="<EFBFBD>®¬®éì";
|
char HELP_WINDOW_CAPTION[]="<EFBFBD>®¬®éì";
|
||||||
char *HELP_TEXT[]={ "Š ª ¨£à âì ¢® Flood-it?",
|
char *HELP_TEXT[]={ "Š ª ¨£à âì ¢® Flood-it?",
|
||||||
"",
|
"",
|
||||||
"‡ ¯®«¨â¥ ¯®«¥ ®¤¨¬ 梥⮬ § ®£à ¨ç¥®¥ ç¨á«® 室®¢.",
|
"‚ë¡¥à¨â¥ 梥â, ¦ ¢ ®¤¨ ¨§ ª¢ ¤à ⨪®¢. Š«¥âª¨ ®ªà áïâáï",
|
||||||
"ˆ£à ç¨ ¥âáï á ¢¥à奩 «¥¢®© ª«¥âª¨. ‚ë¡¥à¨â¥ 梥â, ¦ ¢ ®¤¨ ¨§",
|
"í⨬ 梥⮬ <20>€—ˆ<E28094>€Ÿ ‘ ‚…<E2809A>•<EFBFBD>…‰ ‹…‚މ - â ª ¢ë ¯à¨á®¥¤¨¨â¥",
|
||||||
"ª¢ ¤à ⨪®¢ á«¥¢ , ¨ ª«¥âª¨ ®ªà áïâáï í⨬ 梥⮬ - â ª ¢ë ¯à¨á®¥¤¨¨â¥",
|
"á®á¥¤¨¥ ª«¥âª¨ ⮩ ¦¥ ®ªà ᪨. ‡ å¢ â¨âì ¯®«¥ 㦮 § ",
|
||||||
"á®á¥¤¨¥ ª«¥âª¨ ⮩ ¦¥ ®ªà ᪨. ‡ å¢ â¨âì ¯®«¥ 㦮 § ¬¨¨¬ «ì®¥",
|
"®£à ¨ç¥®¥ ç¨á«® 室®¢. „®áâ㯮 ¤¢ à §¬¥à ¤®áª¨.",
|
||||||
"ç¨á«® 室®¢. <20>®è £®¢ ï áâà ⥣¨ï á ¨â¥à¥áë¬ ¯à¨æ¨¯®¬ - ¨§¬¥¨áì,",
|
|
||||||
"çâ®¡ë ¯®¡¥¤¨âì!",
|
|
||||||
"",
|
"",
|
||||||
"ˆ£à âì â ª¦¥ ¬®¦® ª« ¢¨è ¬¨:",
|
"ˆ£à âì â ª¦¥ ¬®¦® ª« ¢¨è ¬¨:",
|
||||||
"[Q] [W] [E]",
|
"[Q] [W] [E]",
|
||||||
@ -62,28 +57,25 @@ char *BOARD_SIZES[]={ "S", "L", 0 };
|
|||||||
"vajutades nuppudele vasakul. Kui sa muudad värvi pragusel alal,",
|
"vajutades nuppudele vasakul. Kui sa muudad värvi pragusel alal,",
|
||||||
"siis iga kokkupuutuv sama värv muutub samaks. Nii saad ujutada",
|
"siis iga kokkupuutuv sama värv muutub samaks. Nii saad ujutada",
|
||||||
"teised alad mänguväljal üle. Valida saad 2 mänguvälja suuruse",
|
"teised alad mänguväljal üle. Valida saad 2 mänguvälja suuruse",
|
||||||
"vahel. Proovi väli üle ujutada etteandtud käikude arvuga!",
|
"vahel.",
|
||||||
"Kaasahaarav ja lõbus!",
|
|
||||||
"",
|
"",
|
||||||
"Mängida saab ka klaviatuuriga:",
|
"Mängida saab ka klaviatuuriga:",
|
||||||
"[Q] [W] [E]",
|
"[Q] [W] [E]",
|
||||||
"[A] [S] [D]",
|
"[A] [S] [D]",
|
||||||
0};
|
0};
|
||||||
#else
|
#else
|
||||||
char *BUTTON_CAPTIONS[]={ "New Game [F2]", "Help [F1]", "Exit [Esc]", 0};
|
char *BUTTON_CAPTIONS[]={ "Restart [F2]", " Help [F1]", " Exit [Esc]", 0};
|
||||||
char CLICKS_TEXT[]="Clicks: /";
|
char CLICKS_TEXT[]="Clicks: /";
|
||||||
char LEVELS_TEXT[]="Board:";
|
char LEVELS_TEXT[]="Board:";
|
||||||
|
|
||||||
char HELP_WINDOW_CAPTION[]="Help";
|
char HELP_WINDOW_CAPTION[]="Help";
|
||||||
char *HELP_TEXT[]={ "How to play Flood-it?",
|
char *HELP_TEXT[]={ "How to play Flood-it?",
|
||||||
"",
|
"",
|
||||||
"Flood the whole board with one color within the allowed steps.",
|
"You start from the TOP LEFT corner and progress by selecting one",
|
||||||
"You start from the top left corner and progress by selecting one",
|
|
||||||
"of the colored buttons on the left. When you change your current area",
|
"of the colored buttons on the left. When you change your current area",
|
||||||
"color, every adjacent square with the same color also changes, that",
|
"color, every adjacent square with the same color also changes, that",
|
||||||
"way you can flood other areas of the board. Select from 3 sizes of",
|
"way you can flood other areas of the board. Select from 2 sizes of",
|
||||||
"the board and try to flood-it in the least amount of steps!",
|
"the board and try to flood-it in the least amount of steps!",
|
||||||
"Addictive and Fun!",
|
|
||||||
"",
|
"",
|
||||||
"You can also play with keyboard:",
|
"You can also play with keyboard:",
|
||||||
"[Q] [W] [E]",
|
"[Q] [W] [E]",
|
||||||
@ -92,7 +84,7 @@ char *BOARD_SIZES[]={ "S", "L", 0 };
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
unsigned char color_matrix[28*28]; //öâåòà äëÿ ïîëÿ ñ êâàäðàòèêàìè
|
unsigned char color_matrix[28*28]; //our field
|
||||||
|
|
||||||
unsigned char loss_matrix[14*14]={
|
unsigned char loss_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,
|
||||||
@ -132,152 +124,160 @@ void main()
|
|||||||
{
|
{
|
||||||
int key, id;
|
int key, id;
|
||||||
|
|
||||||
|
set_board_size(0); //small board by default
|
||||||
new_game();
|
new_game();
|
||||||
|
|
||||||
loop()
|
loop() switch(WaitEvent())
|
||||||
{
|
{
|
||||||
switch(WaitEvent())
|
case evButton:
|
||||||
{
|
id = GetButtonID();
|
||||||
case evButton:
|
IF (id==1) || (id==4) ExitProcess();
|
||||||
id = GetButtonID();
|
IF (id==2) goto _NEW_GAME_MARK;
|
||||||
IF (id==1) || (id==4) ExitProcess();
|
IF (id==3) goto _HELP_MARK;
|
||||||
IF (id==2) goto _NEW_GAME_MARK;
|
IF (id>=100) {
|
||||||
IF (id==3) goto _HELP_MARK;
|
make_turn(id-100);
|
||||||
IF (id>=100)
|
}
|
||||||
{
|
if (id==10) set_board_size(0);
|
||||||
make_turn(id-100);
|
if (id==11) set_board_size(1);
|
||||||
|
break;
|
||||||
|
case evKey:
|
||||||
|
key = GetKeyScancode();
|
||||||
|
IF (key==01) //Escape
|
||||||
|
ExitProcess();
|
||||||
|
IF (key==59) //F1
|
||||||
|
{
|
||||||
|
_HELP_MARK:
|
||||||
|
CreateThread(#help_thread,#help_window_stak);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (id>=10)
|
IF (key==60) //F2
|
||||||
{
|
{
|
||||||
id=id-10*3;
|
_NEW_GAME_MARK:
|
||||||
|
|
||||||
IF (BLOCK_SIZE == DIFFICULTY_LEV_PARAMS[id]) break; //âûáðàí òîò æå ðàçìåð
|
|
||||||
|
|
||||||
BLOCK_SIZE = DIFFICULTY_LEV_PARAMS[id]; //ðàçìåð êâàäðàòèêà
|
|
||||||
BLOCKS_NUM = DIFFICULTY_LEV_PARAMS[id+1]; //êîëè÷åñòâî êâàäðàòèêîâ ïî Õ è ïî Y
|
|
||||||
MAX_CLICKS = DIFFICULTY_LEV_PARAMS[id+2]; //ìàêñèìàëüíîå êîëè÷åñòâî êëèêîâ äî âûèãðûøà
|
|
||||||
|
|
||||||
new_game();
|
new_game();
|
||||||
|
draw_clicks_num();
|
||||||
MoveSize(-1, -1, BLOCK_SIZE*BLOCKS_NUM +14+USER_PANEL_WIDTH, BLOCK_SIZE*BLOCKS_NUM +GetSkinHeight()+14);
|
draw_field();
|
||||||
}
|
break;
|
||||||
break;
|
}
|
||||||
case evKey:
|
IF (key==16) make_turn(0); //Q
|
||||||
key = GetKeyScancode();
|
IF (key==17) make_turn(1); //W
|
||||||
IF (key==01) //Escape
|
IF (key==18) make_turn(2); //E
|
||||||
ExitProcess();
|
IF (key==30) make_turn(3); //A
|
||||||
IF (key==59) //F1
|
IF (key==31) make_turn(4); //S
|
||||||
{
|
IF (key==32) make_turn(5); //D
|
||||||
_HELP_MARK:
|
break;
|
||||||
CreateThread(#help,#stak);
|
case evReDraw:
|
||||||
}
|
draw_window();
|
||||||
IF (key==60) //F2
|
}
|
||||||
{
|
}
|
||||||
_NEW_GAME_MARK:
|
|
||||||
new_game();
|
void set_board_size(char s)
|
||||||
draw_clicks_num();
|
{
|
||||||
draw_field();
|
if (board_size != s) {
|
||||||
}
|
board_size = s;
|
||||||
IF (key==16) make_turn(0); //Q
|
|
||||||
IF (key==17) make_turn(1); //W
|
BLOCKS_NUM = board_size + 1 * DEFAULT_BLOCK_COUNT;
|
||||||
IF (key==18) make_turn(2); //E
|
MAX_CLICKS = board_size + 1 * DEFAULT_MAX_CLICKS;
|
||||||
IF (key==30) make_turn(3); //A
|
|
||||||
IF (key==31) make_turn(4); //S
|
BLOCK_SIZE = GetScreenHeight() - 70 / BLOCKS_NUM;
|
||||||
IF (key==32) make_turn(5); //D
|
if (BLOCK_SIZE > MAX_BLOCK_SIZE) BLOCK_SIZE = MAX_BLOCK_SIZE;
|
||||||
break;
|
|
||||||
case evReDraw:
|
new_game();
|
||||||
draw_window();
|
|
||||||
}
|
MoveSize(-1, -1, BLOCK_SIZE*BLOCKS_NUM +14+USER_PANEL_WIDTH,
|
||||||
|
BLOCK_SIZE*BLOCKS_NUM +GetSkinHeight()+14);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void make_turn(int turn_id)
|
void make_turn(int turn_id)
|
||||||
{
|
{
|
||||||
IF (color_matrix[0]==turn_id) return; //åñëè öâåò ïåðâîé ôèøêè òàêîé æå, èãíîðèðóåì áåññìûñëåííûé õîä
|
IF (color_matrix[0]==turn_id) return; //ignore no-sence click: first item color is equal to a new color
|
||||||
IF (CLICKS>=MAX_CLICKS) return; //åñëè èãðà çàêîí÷åíà
|
IF (!game_is_ended()) {
|
||||||
|
CLICKS++;
|
||||||
CLICKS++;
|
draw_clicks_num();
|
||||||
draw_clicks_num();
|
fill_field(turn_id);
|
||||||
|
if (!game_is_ended()) draw_field();
|
||||||
fill_field(turn_id);
|
}
|
||||||
draw_field();
|
|
||||||
check_for_end(); //åñëè èãðà çàêîí÷åíà
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void draw_window()
|
void draw_window()
|
||||||
{
|
{
|
||||||
int i, j;
|
int i;
|
||||||
#define BUTTON_SIZE 28
|
#define BUTTON_SIZE 28
|
||||||
|
|
||||||
sc.get();
|
sc.get();
|
||||||
|
|
||||||
DefineAndDrawWindow(300,176, BLOCK_SIZE*BLOCKS_NUM +14+USER_PANEL_WIDTH, BLOCK_SIZE*BLOCKS_NUM +GetSkinHeight()+14, 0x74,sc.work,0,0,"Flood-it!");
|
DefineAndDrawWindow(300,176, BLOCK_SIZE*BLOCKS_NUM +14+USER_PANEL_WIDTH,
|
||||||
|
BLOCK_SIZE*BLOCKS_NUM +GetSkinHeight()+14, 0x74,0,"Flood-it!");
|
||||||
|
|
||||||
//ïðîâåðÿåì íå ñõëîïíóòî ëè îêíî â çàãîëîâîê
|
// Fix rolled-up bug
|
||||||
GetProcessInfo(#Form, SelfInfo);
|
GetProcessInfo(#Form, SelfInfo);
|
||||||
IF (Form.status_window==4) return;
|
IF (Form.status_window==4) return;
|
||||||
|
|
||||||
//çàêðàøèâàåì ôîí -> óìåíüøàåò ïåðåðèñîâêó
|
// Fill background to reduce window redraw
|
||||||
for (i=0;i<=4;i++)
|
for (i=0;i<=4;i++)
|
||||||
{
|
{
|
||||||
IF (i<>4)
|
ESI = sc.work;
|
||||||
DrawRegion(USER_PANEL_WIDTH+i-5,i, BLOCK_SIZE*BLOCKS_NUM +9-i-i, BLOCK_SIZE*BLOCKS_NUM+9-i-i, sc.work);
|
IF (i==4) ESI = sc.work_graph;
|
||||||
else
|
DrawRegion(USER_PANEL_WIDTH+i-5,i, BLOCK_SIZE*BLOCKS_NUM +9-i-i, ESI);
|
||||||
DrawRegion(USER_PANEL_WIDTH+i-5,i, BLOCK_SIZE*BLOCKS_NUM +9-i-i, BLOCK_SIZE*BLOCKS_NUM+9-i-i, sc.work_graph); //îáîäîê
|
|
||||||
}
|
}
|
||||||
DrawBar(0,0, USER_PANEL_WIDTH-5, BLOCK_SIZE*BLOCKS_NUM+10, sc.work);
|
DrawBar(0,0, USER_PANEL_WIDTH-5, BLOCK_SIZE*BLOCKS_NUM+10, sc.work);
|
||||||
|
|
||||||
//êíîïî÷êè çàëèâêè
|
// Main buttons to fill the board
|
||||||
|
#define FILL_BUTTON_SIZE BUTTON_SIZE+8
|
||||||
|
for (i=0;i<6;i++)
|
||||||
|
DefineButton(i%3*FILL_BUTTON_SIZE+17,i/3*FILL_BUTTON_SIZE+15,FILL_BUTTON_SIZE,FILL_BUTTON_SIZE, i+100,FIELD_COLORS[i]);
|
||||||
|
|
||||||
|
// Menu buttons
|
||||||
|
for (i=0;i<3;i++)
|
||||||
|
{
|
||||||
|
DefineButton(17,i*31+140, 13*8+6, 25, i+2,sc.work_button);
|
||||||
|
WriteText(17+4,i*31+146,0x90,sc.work_button_text,BUTTON_CAPTIONS[i],0);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Board size
|
||||||
|
WriteText(17,BLOCKS_NUM*BLOCK_SIZE-25+7,0x90,sc.work_text,#LEVELS_TEXT,0);
|
||||||
for (i=0;i<2;i++)
|
for (i=0;i<2;i++)
|
||||||
for (j=0;j<3;j++)
|
|
||||||
DefineButton(j*BUTTON_SIZE+17,i*BUTTON_SIZE+15,BUTTON_SIZE,BUTTON_SIZE, i*3+j+100,FIELD_COLORS[i*3+j]);
|
|
||||||
|
|
||||||
//êíîïî÷êè äåéñòâèé
|
|
||||||
for (j=0;j<3;j++)
|
|
||||||
{
|
{
|
||||||
DefineButton(17,j*25+120, 13*6+6, 20, j+2,sc.work_button);
|
IF (board_size == i) {
|
||||||
WriteText(17+4,j*25+127,0x80,sc.work_button_text,BUTTON_CAPTIONS[j],0);
|
ESI=sc.work_button;
|
||||||
}
|
EDI=sc.work_button_text;
|
||||||
|
} ELSE {
|
||||||
|
ESI = sc.work;
|
||||||
|
EDI = sc.work_text;
|
||||||
|
}
|
||||||
|
|
||||||
//êíîïî÷êè âûáîðà óðîâíÿ ñëîæíîñòè
|
DefineButton(i*32+69,BLOCKS_NUM*BLOCK_SIZE-24, 26,25, i+10,ESI);
|
||||||
WriteText(17,BLOCKS_NUM*BLOCK_SIZE-20+7,0x80,sc.work_text,#LEVELS_TEXT,0);
|
WriteText(i*32+69+9,BLOCKS_NUM*BLOCK_SIZE-24+6,0x90,EDI,#BOARD_SIZES+i+i,0);
|
||||||
for (j=0;j<2;j++)
|
$add ebx, 1<<16 //bold
|
||||||
{
|
$int 0x40
|
||||||
DefineButton(j*25+56,BLOCKS_NUM*BLOCK_SIZE-20, 20,20, j+10,sc.work_button);
|
|
||||||
|
|
||||||
IF (BLOCK_SIZE == DIFFICULTY_LEV_PARAMS[j*3]) EDI=0x800080;
|
|
||||||
else EDI=sc.work_button_text;
|
|
||||||
|
|
||||||
WriteText(j*25+56+8,BLOCKS_NUM*BLOCK_SIZE-20+7,0x80,EDI,BOARD_SIZES[j],0);
|
|
||||||
WriteText(j*25+56+9,BLOCKS_NUM*BLOCK_SIZE-20+7,0x80,EDI,BOARD_SIZES[j],0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
draw_clicks_num();
|
draw_clicks_num();
|
||||||
|
|
||||||
draw_field();
|
draw_field();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void randomly_fill_the_board()
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
for (i=0;i<BLOCKS_NUM*BLOCKS_NUM;i++) {
|
||||||
|
color_matrix[i] = random(6);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void new_game()
|
void new_game()
|
||||||
{
|
{
|
||||||
int i;
|
|
||||||
|
|
||||||
CLICKS = 0;
|
CLICKS = 0;
|
||||||
|
game_end = false;
|
||||||
for (i=0;i<BLOCKS_NUM*BLOCKS_NUM;i++)
|
randomly_fill_the_board();
|
||||||
color_matrix[i] = random(6);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void fill_field(int new_color_id)
|
void fill_field(int new_color_id)
|
||||||
{
|
{
|
||||||
int i, j,
|
int i, j,
|
||||||
old_color_id=color_matrix[0],
|
old_color_id=color_matrix[0],
|
||||||
restart;
|
restart;
|
||||||
|
int cur_cell;
|
||||||
#define MARKED 6
|
#define MARKED 6
|
||||||
|
|
||||||
color_matrix[0]=MARKED;
|
color_matrix[0]=MARKED;
|
||||||
@ -289,15 +289,16 @@ void fill_field(int new_color_id)
|
|||||||
for (i=0;i<BLOCKS_NUM;i++)
|
for (i=0;i<BLOCKS_NUM;i++)
|
||||||
for (j=0;j<BLOCKS_NUM;j++)
|
for (j=0;j<BLOCKS_NUM;j++)
|
||||||
{
|
{
|
||||||
IF (color_matrix[i*BLOCKS_NUM+j]<>old_color_id) continue; //åñëè ôèøêà íå íóæíîãî öâåòà èä¸ì äàëüøå
|
cur_cell = i*BLOCKS_NUM+j;
|
||||||
IF (color_matrix[i*BLOCKS_NUM+j]==MARKED) continue; //åñëè ôèøêà óæå îòìå÷åíà, èä¸ì äàëåå
|
IF (color_matrix[cur_cell]<>old_color_id) continue; //if not a needed color then continue
|
||||||
|
IF (color_matrix[cur_cell]==MARKED) continue; //if already marked then continue
|
||||||
|
|
||||||
IF (j>0) && (color_matrix[i*BLOCKS_NUM+j-1]==MARKED) color_matrix[i*BLOCKS_NUM+j]=MARKED; //ñìîòðèì ëåâûé
|
IF (j>0) && (color_matrix[i*BLOCKS_NUM+j-1]==MARKED) color_matrix[cur_cell]=MARKED; //left
|
||||||
IF (i>0) && (color_matrix[i-1*BLOCKS_NUM+j]==MARKED) color_matrix[i*BLOCKS_NUM+j]=MARKED; //ñìîòðèì âåðõíèé
|
IF (i>0) && (color_matrix[i-1*BLOCKS_NUM+j]==MARKED) color_matrix[cur_cell]=MARKED; //top
|
||||||
IF (j<BLOCKS_NUM-1) && (color_matrix[i*BLOCKS_NUM+j+1]==MARKED) color_matrix[i*BLOCKS_NUM+j]=MARKED; //ñìîòðèì ïðàâûé
|
IF (j<BLOCKS_NUM-1) && (color_matrix[i*BLOCKS_NUM+j+1]==MARKED) color_matrix[cur_cell]=MARKED; //right
|
||||||
IF (i<BLOCKS_NUM-1) && (color_matrix[i+1*BLOCKS_NUM+j]==MARKED) color_matrix[i*BLOCKS_NUM+j]=MARKED; //ñìîòðèì íèæíèé
|
IF (i<BLOCKS_NUM-1) && (color_matrix[i+1*BLOCKS_NUM+j]==MARKED) color_matrix[cur_cell]=MARKED; //bottom
|
||||||
|
|
||||||
IF (color_matrix[i*BLOCKS_NUM+j]==MARKED) restart=1; //åñëè ôèøêó îòìåòèëè, òî ïîòîì öèêë íóæíî áóäåò ïðîêðóòèòü ñíà÷àëà - ìîæ åù¸ ÷¸ îòìåòèì
|
IF (color_matrix[cur_cell]==MARKED) restart=1;
|
||||||
}
|
}
|
||||||
IF (restart) goto _RESTART_MARK;
|
IF (restart) goto _RESTART_MARK;
|
||||||
|
|
||||||
@ -305,101 +306,83 @@ void fill_field(int new_color_id)
|
|||||||
IF (color_matrix[i]==MARKED) color_matrix[i]=new_color_id;
|
IF (color_matrix[i]==MARKED) color_matrix[i]=new_color_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void draw_win_or_loose_animation(dword matrix)
|
||||||
int check_for_end()
|
|
||||||
{
|
{
|
||||||
int i, j, ii, jj;
|
int i, j, ii, jj;
|
||||||
|
for (i=0;i<14;i++) {
|
||||||
if (CLICKS>=MAX_CLICKS) //åñëè ïðîèãðûø
|
|
||||||
{
|
|
||||||
IF (CLICKS==MAX_CLICKS) //âûèãðûøü íà ïîñëåäíåì õîäå
|
|
||||||
{
|
|
||||||
for (i=0;i<BLOCKS_NUM*BLOCKS_NUM;i++) //ïðîâåðÿåì âñ¸ ëè ïîëå îäíîãî öâåòà, åñëè íåò óõîäèì
|
|
||||||
IF (color_matrix[i]<>color_matrix[0]) goto _loss_MARK;
|
|
||||||
goto _WIN_MARK;
|
|
||||||
}
|
|
||||||
|
|
||||||
_loss_MARK:
|
|
||||||
|
|
||||||
for (i=0;i<14;i++)
|
|
||||||
for (j=0;j<14;j++)
|
|
||||||
{
|
|
||||||
IF (BLOCK_SIZE == DIFFICULTY_LEV_PARAMS[0])
|
|
||||||
{
|
|
||||||
ii=i;
|
|
||||||
jj=j;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ii=i*2;
|
|
||||||
jj=j*2;
|
|
||||||
}
|
|
||||||
color_matrix[ii*BLOCKS_NUM+jj]=loss_matrix[i*14+j];
|
|
||||||
color_matrix[ii+1*BLOCKS_NUM+jj]=loss_matrix[i*14+j];
|
|
||||||
color_matrix[ii*BLOCKS_NUM+jj+1]=loss_matrix[i*14+j];
|
|
||||||
color_matrix[ii+1*BLOCKS_NUM+jj+1]=loss_matrix[i*14+j];
|
|
||||||
draw_field();
|
|
||||||
//Pause(5);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i=0;i<BLOCKS_NUM*BLOCKS_NUM;i++) //ïðîâåðÿåì âñ¸ ëè ïîëå îäíîãî öâåòà, åñëè íåò óõîäèì
|
|
||||||
IF (color_matrix[i]<>color_matrix[0]) return 0;
|
|
||||||
|
|
||||||
//âñ¸ ïîëå îäíîãî öâåòà è ôèøåê ìåíüøå MAX_CLICKS -> ïîáåäà
|
|
||||||
|
|
||||||
_WIN_MARK:
|
|
||||||
|
|
||||||
for (i=0;i<25;i++)
|
|
||||||
{
|
|
||||||
new_game();
|
|
||||||
draw_field();
|
|
||||||
Pause(7);
|
|
||||||
}
|
|
||||||
|
|
||||||
CLICKS=MAX_CLICKS;
|
|
||||||
|
|
||||||
for (i=0;i<14;i++)
|
|
||||||
for (j=0;j<14;j++)
|
for (j=0;j<14;j++)
|
||||||
{
|
{
|
||||||
IF (BLOCK_SIZE == DIFFICULTY_LEV_PARAMS[0]) //çàëèâêà äëÿ ïîëåé ðàçíîãî ðàçìåðà ðàçíàÿ
|
ii = board_size * 2 + i;
|
||||||
{
|
jj = board_size * 2 + j;
|
||||||
ii=i;
|
color_matrix[ii*BLOCKS_NUM+jj]=
|
||||||
jj=j;
|
color_matrix[ii+1*BLOCKS_NUM+jj]=
|
||||||
}
|
color_matrix[ii*BLOCKS_NUM+jj+1]=
|
||||||
else
|
color_matrix[ii+1*BLOCKS_NUM+jj+1]=ESBYTE[i*14+j+matrix];
|
||||||
{
|
draw_field();
|
||||||
ii=i*2;
|
}
|
||||||
jj=j*2;
|
}
|
||||||
}
|
}
|
||||||
color_matrix[ii*BLOCKS_NUM+jj]=win_matrix[i*14+j];
|
|
||||||
color_matrix[ii+1*BLOCKS_NUM+jj]=win_matrix[i*14+j];
|
int field_is_solid()
|
||||||
color_matrix[ii*BLOCKS_NUM+jj+1]=win_matrix[i*14+j];
|
{
|
||||||
color_matrix[ii+1*BLOCKS_NUM+jj+1]=win_matrix[i*14+j];
|
int i;
|
||||||
|
if (game_end) return 1;
|
||||||
|
game_end = 1;
|
||||||
|
for (i=0;i<BLOCKS_NUM*BLOCKS_NUM;i++) {
|
||||||
|
IF (color_matrix[i]<>color_matrix[0]) game_end = 0;
|
||||||
|
}
|
||||||
|
return game_end;
|
||||||
|
}
|
||||||
|
|
||||||
|
int game_is_ended()
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
if (game_end) return 1;
|
||||||
|
|
||||||
|
if (CLICKS>=MAX_CLICKS) //check for game end via max_clicks
|
||||||
|
{
|
||||||
|
IF (CLICKS==MAX_CLICKS) //probably user won on the last step
|
||||||
|
{
|
||||||
|
if (field_is_solid()) goto _WIN_MARK;
|
||||||
|
}
|
||||||
|
draw_win_or_loose_animation(#loss_matrix);
|
||||||
|
return 1;
|
||||||
|
} else {
|
||||||
|
if (!field_is_solid()) return 0;
|
||||||
|
|
||||||
|
//field is solid and CLICKS<MAX_CLICKS -> win
|
||||||
|
|
||||||
|
_WIN_MARK:
|
||||||
|
|
||||||
|
for (i=0;i<25;i++)
|
||||||
|
{
|
||||||
|
randomly_fill_the_board();
|
||||||
draw_field();
|
draw_field();
|
||||||
//Pause(5);
|
Pause(7);
|
||||||
}
|
}
|
||||||
return 1;
|
|
||||||
|
draw_win_or_loose_animation(#win_matrix);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void draw_clicks_num()
|
void draw_clicks_num()
|
||||||
{
|
{
|
||||||
#define TEXT_X 21
|
#define TEXT_X 19
|
||||||
#define TEXT_Y 92
|
#define TEXT_Y 100
|
||||||
|
|
||||||
DrawBar(TEXT_X, TEXT_Y, USER_PANEL_WIDTH-TEXT_X-3,9, sc.work);
|
DrawBar(TEXT_X, TEXT_Y, USER_PANEL_WIDTH-TEXT_X-5,16, sc.work);
|
||||||
|
|
||||||
WriteText(TEXT_X,TEXT_Y,0x80,sc.work_text,#CLICKS_TEXT,0);
|
WriteText(TEXT_X,TEXT_Y,0x90,sc.work_text,#CLICKS_TEXT,0);
|
||||||
|
|
||||||
IF (CLICKS<10) EBX=9*6+TEXT_X;
|
IF (CLICKS<10) EBX=9*8+TEXT_X;
|
||||||
else EBX=8*6+TEXT_X;
|
else EBX=8*8+TEXT_X;
|
||||||
|
|
||||||
WriteText(EBX,TEXT_Y,0x80,sc.work_text,IntToStr(CLICKS),0);
|
WriteText(EBX,TEXT_Y,0x90,sc.work_text,itoa_nosign(CLICKS),0);
|
||||||
|
|
||||||
WriteText(11*6+TEXT_X,TEXT_Y,0x80,sc.work_text,IntToStr(MAX_CLICKS),0);
|
WriteText(11*8+TEXT_X,TEXT_Y,0x90,sc.work_text,itoa_nosign(MAX_CLICKS),0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -417,7 +400,7 @@ void draw_field()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void help()
|
void help_thread()
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@ -429,10 +412,10 @@ void help()
|
|||||||
IF (GetKeyScancode()==001) ExitProcess(); //Esc
|
IF (GetKeyScancode()==001) ExitProcess(); //Esc
|
||||||
break;
|
break;
|
||||||
case evReDraw:
|
case evReDraw:
|
||||||
for (i=0; HELP_TEXT[i]<>0; i++;) {};
|
//for (i=0; HELP_TEXT[i]<>0; i++;) {}; //calculate line numbers, predefined i=12 used to reduce size
|
||||||
DefineAndDrawWindow(400,200,610,i*19+25+GetSkinHeight(),0x34,sc.work,0,0,#HELP_WINDOW_CAPTION);
|
DefineAndDrawWindow(400,200,612,12*19+25+GetSkinHeight(),0x34,sc.work,#HELP_WINDOW_CAPTION);
|
||||||
WriteText(6,12,0x90,sc.work_text,HELP_TEXT[0],0); //ýòî äëÿ æèðíîãî øðèôòà
|
WriteText(6,12,0x90,sc.work_text,HELP_TEXT[0],0); //for a bold text
|
||||||
for (i=0; HELP_TEXT[i]<>0; i++;) WriteText(5,i*19+12,0x90,sc.work_text,HELP_TEXT[i],0);
|
for (i=0; HELP_TEXT[i]<>0; i++;) WriteText(7,i*19+12,0x90,sc.work_text,HELP_TEXT[i],0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,6 +23,10 @@ dword I_Path = 0;
|
|||||||
#define BT_HIDE 0x40000000
|
#define BT_HIDE 0x40000000
|
||||||
#define BT_NOFRAME 0x20000000
|
#define BT_NOFRAME 0x20000000
|
||||||
|
|
||||||
|
#define bool char
|
||||||
|
#define true 1
|
||||||
|
#define false 0
|
||||||
|
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
@ -94,16 +98,11 @@ inline fastcall Pause(dword EBX)
|
|||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
char buffer[11]="";
|
char buffer[5];
|
||||||
inline fastcall dword IntToStr(dword ESI)
|
inline fastcall dword itoa_nosign(dword ESI)
|
||||||
{
|
{
|
||||||
$mov edi, #buffer
|
$mov edi, #buffer
|
||||||
$mov ecx, 10
|
$mov ecx, 10
|
||||||
$test esi, esi
|
|
||||||
$jns f1
|
|
||||||
$mov al, '-'
|
|
||||||
$stosb
|
|
||||||
$neg esi
|
|
||||||
f1:
|
f1:
|
||||||
$mov eax, esi
|
$mov eax, esi
|
||||||
$push -'0'
|
$push -'0'
|
||||||
@ -126,7 +125,7 @@ f3:
|
|||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
void DefineAndDrawWindow(dword x,y,sizeX,sizeY,byte mainAreaType,dword mainAreaColour,byte headerType,dword headerColour,EDI)
|
void DefineAndDrawWindow(dword x,y,sizeX,sizeY,byte mainAreaType,dword mainAreaColour,EDI)
|
||||||
{
|
{
|
||||||
EAX = 12; // function 12:tell os about windowdraw
|
EAX = 12; // function 12:tell os about windowdraw
|
||||||
EBX = 1;
|
EBX = 1;
|
||||||
@ -135,7 +134,7 @@ void DefineAndDrawWindow(dword x,y,sizeX,sizeY,byte mainAreaType,dword mainAreaC
|
|||||||
EBX = x << 16 + sizeX;
|
EBX = x << 16 + sizeX;
|
||||||
ECX = y << 16 + sizeY;
|
ECX = y << 16 + sizeY;
|
||||||
EDX = mainAreaType << 24 | mainAreaColour;
|
EDX = mainAreaType << 24 | mainAreaColour;
|
||||||
ESI = headerType << 24 | headerColour;
|
ESI = 0;
|
||||||
$xor eax,eax
|
$xor eax,eax
|
||||||
$int 0x40
|
$int 0x40
|
||||||
|
|
||||||
@ -166,6 +165,13 @@ dword GetSkinHeight()
|
|||||||
$pop ebx
|
$pop ebx
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline fastcall int GetScreenHeight()
|
||||||
|
{
|
||||||
|
$mov eax, 14
|
||||||
|
$int 0x40
|
||||||
|
$and eax,0x0000FFFF
|
||||||
|
}
|
||||||
|
|
||||||
void WriteText(dword x,y,byte fontType, dword color, EDX, ESI)
|
void WriteText(dword x,y,byte fontType, dword color, EDX, ESI)
|
||||||
{
|
{
|
||||||
EAX = 4;
|
EAX = 4;
|
||||||
@ -190,12 +196,20 @@ void DefineButton(dword x,y,w,h,EDX,ESI)
|
|||||||
$int 0x40
|
$int 0x40
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawRegion(dword x,y,width,height,EDX)
|
void DrawRegion(dword x,y,s,EDX)
|
||||||
{
|
{
|
||||||
DrawBar(x,y,width,1,EDX);
|
EAX = 13;
|
||||||
DrawBar(x,y+height,width,1,EDX);
|
EBX = x<<16+s;
|
||||||
DrawBar(x,y,1,height,EDX);
|
ECX = y<<16+1;
|
||||||
DrawBar(x+width,y,1,height+1,EDX);
|
$int 0x40
|
||||||
|
ECX = y+s<<16+1;
|
||||||
|
$int 0x40
|
||||||
|
EBX = x<<16+1;
|
||||||
|
ECX = y<<16+s;
|
||||||
|
$int 0x40
|
||||||
|
EBX = x+s<<16+1;
|
||||||
|
ECX = y<<16+s+1;
|
||||||
|
$int 0x40
|
||||||
}
|
}
|
||||||
|
|
||||||
inline fastcall dword WriteDebug(dword EDX)
|
inline fastcall dword WriteDebug(dword EDX)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user