-
Notifications
You must be signed in to change notification settings - Fork 0
/
popstar introduction.txt
2905 lines (2011 loc) · 59.6 KB
/
popstar introduction.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#include <graphics.h>
#include<Windows.h>
#include <stdio.h>
#include <time.h>
#include <math.h>
#include <conio.h>
//#include "tools.h"
#include <mmsystem.h> //播放背景音乐和音效的头文件
#pragma comment(lib,"winmm.lib") //播放音乐需要的库文件
#include <tchar.h>
#pragma comment(lib,"WinMM.lib")
#pragma warning(disable:4996)
#define N 40//方块边长
#define WIN_WIDHT 600
#define WIN_HEIGHT 1000
#define ROWS 10
#define COLS 10
#define BLOCK_TYPE_COUNT 7
#define difficulty 6
IMAGE imaBg;
IMAGE imgBlocks[BLOCK_TYPE_COUNT];
struct block
{
int type;//表示方块
int x, y;
int row, col;
int match;
int tmd;//透明度:0-255,0完全透明
int exist;
};
struct block map[ROWS + 2][COLS + 2];
const int off_x = 75;
const int off_y = 340;
const int blocks_size = 45;
const int gap_size = 0;
int TargetScore;
int GameLevel;
int Click1, Click2, Click3;//技能:锤子,重排,交换
int posX1, posY1;
int changeX1, changeY1, changeX2, changeY2;
int Flag1;
bool propsing;
bool isMoving;
bool swap;
bool proper;
int score;
int userover;
int starLeave;
int click1 = 0;//锤子
int click2 = 0;//刷新
int click3 = 0;//交换
int flag1 = 0;//工具使用
//库内定义
IMAGE background_image;//游戏页面背景图片
IMAGE RegbgImage;//注册页面背景图片
IMAGE nowImage; //当前
MOUSEMSG m; //鼠标
//MOUSEMSG m;
COLORREF colorArr[6] = { RGB(200, 0, 0), RGB(0, 200, 0),RGB(0,0,200),RGB(0, 200, 200), RGB(200, 0, 200),RGB(200,200,0) };//颜色池(红,绿,蓝,青,紫,黄)
//结构体定义
typedef struct position//位置结构体
{
int x;
int y;
}pos; //位置信息
//全局变量
pos mou; //鼠标位置结构体
pos sameArr[100]; //同色方块坐标
int index = 0; //同色方块个数
int mark = 0;//积分
int level = 1;//关卡数
int target = 0;//目标分
int levelTemp = 1;//关卡数储存
int GamePhase; //处于哪一个界面
//函数声明
void Game(char c);//光明模式
void loadData();//读取数据
void recordData();//保存数据
void game(void); //初始化游戏界面
void playgame(void); //游戏玩法
int GetSameColor(pos, COLORREF);//获取同颜色的方块
int IsTheSame(pos, COLORREF); //判断方块附近颜色是否一样
void falling(void); //方块下落移动
void Checking(void);//检查残局并结束游戏
void StartDraw();//开始界面
void MainMenuOp();//主菜单操作
void StartGameOp();//开始游戏操作
void KeepGameOp();//继续游戏操作
void HelpOp();//帮助操作
void OverOp();//结束操作
void Start();//开始游戏界面
void Keep();//继续游戏界面
void help();//帮助界面
void mouse(); //鼠标操作
void Game1();//游戏-无尽模式
void popstar();//游戏主体
void InitMap();//初始化map
void init(char c);//初始化方块
//主程序
int main()
{
initgraph(640, 500);//创建窗体
srand((unsigned)time(NULL));//随机种子
rectangle(10, 10, 630, 470);//创建矩形
// 获取窗口句柄
HWND hwnd = GetHWnd();
// 设置窗口标题文字
SetWindowText(hwnd, "Popstar! 消灭星星!");
//初始化菜单界面
StartDraw();
//界面操控标识
GamePhase = 0;
//游戏循环
while (1)
{
m = GetMouseMsg();//获取鼠标操作
mouse();
}
getch();
closegraph();
}
//开始界面绘制
void StartDraw()
{
//标题
settextstyle(52, 30, _T("幼圆"));//字的长度(52) 和 宽度(30)
settextcolor(RGB(255, 255, 0));
outtextxy(40, 40, _T("Popstar!消灭星星☆"));
//作者
settextstyle(20, 10, _T("幼圆"));
settextcolor(RGB(255, 51, 68));
outtextxy(300, 103, _T("小组成员:周毅康、易梦哲、高祥"));
//开始游戏
rectangle(240, 150, 365, 185);
settextstyle(22, 12, _T("微软雅黑"));
settextcolor(RGB(255, 51, 68));
outtextxy(250, 155, _T("开始游戏"));
//继续游戏
rectangle(240, 230, 365, 265);
settextstyle(22, 12, _T("微软雅黑"));
settextcolor(RGB(255, 51, 68));
outtextxy(250, 235, _T("继续游戏"));
//帮助
rectangle(240, 310, 365, 345);
settextstyle(22, 12, _T("微软雅黑"));
settextcolor(RGB(255, 51, 68));
outtextxy(250, 315, _T("游戏帮助"));
//退出游戏
rectangle(240, 390, 365, 425);
settextstyle(22, 12, _T("微软雅黑"));
settextcolor(RGB(255, 51, 68));
outtextxy(250, 395, _T("退出游戏"));
//环境
settextcolor(RGB(255, 255, 255));
outtextxy(90, 460, _T("Programing by Visual Studio && EasyX"));
}
//鼠标操作
void mouse()
{
//音乐
mciSendString("open res/menuBg.mp3 alias menuBg", 0, 0, 0);
mciSendString("play menuBg repeat", 0, 0, 0);
mciSendString("setaudio menuBg volume to 100", 0, 0, 0);
//主菜单界面
if (GamePhase == 0)
{
//主菜单操作
MainMenuOp();
}
//开始游戏
if (GamePhase == 1)
{
//开始游戏操作
StartGameOp();
}
//继续游戏
if (GamePhase == 2)
{
//继续游戏操作
KeepGameOp();
}
//帮助界面
if (GamePhase == 3)
{
//帮助操作
HelpOp();
}
//结束界面
if (GamePhase == 4)
{
//结束操作
OverOp();
}
//清除鼠标消息队列
FlushMouseMsgBuffer();
}
//开始游戏界面
void Start()
{
//光明模式
rectangle(250, 190, 365, 225);
settextstyle(22, 12, _T("微软雅黑"));
settextcolor(RGB(255, 51, 68));
outtextxy(260, 195, _T("光明模式"));
//无尽模式
rectangle(250, 270, 365, 305);
settextstyle(22, 12, _T("微软雅黑"));
settextcolor(RGB(255, 51, 68));
outtextxy(260, 275, _T("无尽模式"));
//返回
rectangle(250, 350, 325, 385);
settextstyle(22, 12, _T("微软雅黑"));
settextcolor(RGB(255, 51, 68));
outtextxy(260, 355, _T("返回"));
}
//继续游戏界面
void Keep()
{
//光明模式
rectangle(250, 190, 365, 225);
settextstyle(22, 12, _T("微软雅黑"));
settextcolor(RGB(255, 51, 68));
outtextxy(260, 195, _T("光明模式"));
//无尽模式
rectangle(250, 270, 365, 305);
settextstyle(22, 12, _T("微软雅黑"));
settextcolor(RGB(255, 51, 68));
outtextxy(260, 275, _T("无尽模式"));
//返回
rectangle(250, 350, 325, 385);
settextstyle(22, 12, _T("微软雅黑"));
settextcolor(RGB(255, 51, 68));
outtextxy(260, 355, _T("返回"));
}
//帮助界面
void help()
{
//提示语
settextstyle(30, 0, _T("微软雅黑"));
outtextxy(210, 150, _T("没有帮助,自己摸索去吧!"));
//返回
rectangle(250, 360, 325, 395);
settextstyle(22, 12, _T("微软雅黑"));
settextcolor(RGB(255, 51, 68));
outtextxy(260, 365, _T("返回"));
}
//游戏模式-无尽模式
void Game1()
{
//初始化窗口
initgraph(700, 700);
//游戏初始界面
game();
//游戏运行
playgame();
//界面暂停,不退出
system("pause");
}
//设置起全文字体的函数
void setFont(const char* fontName, int fontWidth, int fontHeight)
{
LOGFONT f;
gettextstyle(&f);
f.lfHeight = fontHeight; // 设置字体高度为 48
f.lfWidth = fontWidth;
strcpy(f.lfFaceName, fontName); // 设置字体为“黑体”(高版本 VC 推荐使用 _tcscpy_s 函数)
f.lfQuality = ANTIALIASED_QUALITY; // 设置输出效果为抗锯齿
setbkmode(TRANSPARENT);
settextstyle(&f);
}
void init(char c)
{
initgraph(WIN_WIDHT, WIN_HEIGHT);
loadimage(&imaBg, "res/gamebg.png");
char name[64];
for (int i = 0; i < BLOCK_TYPE_COUNT; i++)
{
sprintf_s(name, sizeof(name), "res/%d.png", i + 1);
loadimage(&imgBlocks[i], name, blocks_size, blocks_size, true);
}
srand(time(NULL));
if (c == 0)
{
InitMap();
}
isMoving = false;
propsing = false;
Click1 = 0;
Click2 = 0;
Click3 = 0;
swap = false;
proper = false;
Flag1 = 1;
if (c == 0)
{
score = 0;
starLeave = 50;
}
userover = 0;
setFont("Segoe UI Black", 20, 40); //设置全文字体
//播放背景音乐
mciSendString("open res/bg.mp3 alias bgm1", 0, 0, 0);
mciSendString("play bgm1 repeat", 0, 0, 0);
mciSendString("setaudio bgm1 volume to 60", 0, 0, 0);
mciSendString("open res/start.mp3 alias startbgm", 0, 0, 0);
mciSendString("play startbgm", 0, 0, 0);
mciSendString("setaudio startbgm volume to 60", 0, 0, 0);
}
void InitMap()
{
for (int i = 1; i <= ROWS; i++)
{
for (int j = 1; j <= COLS; j++)
{
map[i][j].type = rand() % difficulty + 1;
map[i][j].row = i;
map[i][j].col = j;
map[i][j].x = off_x + (j - 1) * (blocks_size + gap_size);
map[i][j].y = off_y + (i - 1) * (blocks_size + gap_size);
map[i][j].match = 0;
map[i][j].tmd = 255;
map[i][j].exist = 1;
}
}
}
void putimageTMD(int picture_x, int picture_y, IMAGE* picture, int tmd) //x为载入图片的X坐标,y为Y坐标
{
if (picture_y < 0)return;
DWORD* dst = GetImageBuffer(); // GetImageBuffer()函数,用于获取绘图设备的显存指针,EASYX自带
DWORD* draw = GetImageBuffer();
DWORD* src = GetImageBuffer(picture); //获取picture的显存指针
int picture_width = picture->getwidth(); //获取picture的宽度,EASYX自带
int picture_height = picture->getheight(); //获取picture的高度,EASYX自带
int graphWidth = getwidth(); //获取绘图区的宽度,EASYX自带
int graphHeight = getheight(); //获取绘图区的高度,EASYX自带
int dstX = 0; //在显存里像素的角标
// 实现透明贴图 公式: Cp=αp*FP+(1-αp)*BP , 贝叶斯定理来进行点颜色的概率计算
for (int iy = 0; iy < picture_height; iy++)
{
for (int ix = 0; ix < picture_width; ix++)
{
int srcX = ix + iy * picture_width; //在显存里像素的角标
int sa = ((src[srcX] & 0xff000000) >> 24); //0xAArrggbb;AA是透明度
if (tmd < 255)
{
if (sa > 200) sa = tmd;
else continue;
}
int sr = ((src[srcX] & 0xff0000) >> 16); //获取RGB里的R
int sg = ((src[srcX] & 0xff00) >> 8); //G
int sb = src[srcX] & 0xff; //B
if (ix >= 0 && ix <= graphWidth && iy >= 0 && iy <= graphHeight && dstX <= graphWidth * graphHeight)
{
dstX = (ix + picture_x) + (iy + picture_y) * graphWidth; //在显存里像素的角标
int dr = ((dst[dstX] & 0xff0000) >> 16);
int dg = ((dst[dstX] & 0xff00) >> 8);
int db = dst[dstX] & 0xff;
draw[dstX] = ((sr * sa / 255 + dr * (255 - sa) / 255) << 16)
| ((sg * sa / 255 + dg * (255 - sa) / 255) << 8)
| (sb * sa / 255 + db * (255 - sa) / 255);
}
}
}
}
void recordData()
{
FILE* inFile = fopen("gamedata.dat", "wb");
fwrite(map, sizeof(struct block), (COLS + 2) * (ROWS + 2), inFile);
fwrite(&score, sizeof(int), 1, inFile);
fwrite(&starLeave, sizeof(int), 1, inFile);
fwrite(&GameLevel, sizeof(int), 1, inFile);
fclose(inFile);
}
void loadData()
{
FILE* tmpFile = fopen("gamedata.dat", "rb");
fread(map, sizeof(struct block), (COLS + 2) * (ROWS + 2), tmpFile);
fread(&score, sizeof(int), 1, tmpFile);
fread(&starLeave, sizeof(int), 1, tmpFile);
fread(&GameLevel, sizeof(int), 1, tmpFile);
fclose(tmpFile);
}
void updateWindow()
{
BeginBatchDraw();
putimage(0, 0, &imaBg);
for (int i = 1; i <= ROWS; i++)
{
for (int j = 1; j <= COLS; j++)
{
if (map[i][j].type && map[i][j].exist)
{
IMAGE* img = &imgBlocks[map[i][j].type - 1];
putimageTMD(map[i][j].x, map[i][j].y, img, map[i][j].tmd);//使图像拥有透明度
}
}
}
char levelStr[16];
sprintf_s(levelStr, sizeof(levelStr), "%d", GameLevel);
int x1 = 100;
outtextxy(x1, 48, levelStr);
char targerStr[16];
sprintf_s(targerStr, sizeof(targerStr), "%d", TargetScore);
int x2 = 257 + (110 - strlen(targerStr) * 20) / 2;
outtextxy(x2, 44, targerStr);
char scoreStr[16];
sprintf_s(scoreStr, sizeof(scoreStr), "%d", score);
int x = 204 + (144 - strlen(scoreStr) * 20) / 2;
outtextxy(x, 128, scoreStr);
char starStr[16];
sprintf_s(starStr, sizeof(starStr), "%d", starLeave);
int x3 = 476 + (62 - strlen(starStr) * 20) / 2;
outtextxy(x3, 129, starStr);
EndBatchDraw();
}
void exchange(int row1, int col1, int row2, int col2)
{
struct block temp = map[row1][col1];
map[row1][col1] = map[row2][col2];
map[row2][col2] = temp;
map[row1][col1].row = row1;
map[row1][col1].col = col1;
map[row2][col2].row = row2;
map[row2][col2].col = col2;
}
bool isInRect(ExMessage* msg, int x, int y, int w, int h)
{
if (msg->x > x && msg->x<x + w && msg->y>y && msg->y < y + h)
{
return true;
}
return false;
}
void userClick()
{
ExMessage msg;
if (peekmessage(&msg))
{
if (msg.message == WM_RBUTTONDOWN)
{
Click1 = Click2 = Click3 = 0;
}
if (msg.message == WM_LBUTTONDOWN)
{
if (isInRect(&msg, 28, 133, 43, 39))
{
userover = 1;
recordData();
}
else if (isInRect(&msg, 543, 137, 37, 37))
{
system("start https://www.bilibili.com/video/BV1J4411v7g6/?vd_source=4a9f5fae5a1a17a41db46af9fb8d7a5c");
}
else if (isInRect(&msg, 305, 226, 75, 75) && starLeave >= 10)
{
Click1 = 1;
Click2 = Click3 = 0;
}
else if (isInRect(&msg, 405, 226, 75, 75) && starLeave >= 25)
{
Click2 = 1;
Click1 = Click3 = 0;
}
else if (isInRect(&msg, 505, 226, 75, 75) && starLeave >= 10)
{
Click3 = 1;
Click1 = Click2 = 0;
}
else
{
if (msg.x < off_x || msg.y < off_y) return;
int col = (msg.x - off_x) / (blocks_size + gap_size) + 1;
int row = (msg.y - off_y) / (blocks_size + gap_size) + 1;
if (col > COLS || row > ROWS || map[row][col].exist == 0) return;
if (Click1 == 1 && map[row][col].exist)
{
PlaySound("res/clear.wav", 0, SND_FILENAME | SND_ASYNC);
starLeave = starLeave - 10;
map[row][col].match = 1;
map[row][col].tmd = 0;
score = score + 10;
Click1 = 0;
propsing = false;
return;
}
else if (Click3 >= 1)
{
if (map[row][col].exist) Click3++;
if (Click3 == 2)
{
changeX1 = row;
changeY1 = col;
return;
}
else if (Click3 == 3)
{
PlaySound("res/blockChange.wav", 0, SND_FILENAME | SND_ASYNC);
starLeave = starLeave - 10;
changeX2 = row;
changeY2 = col;
int temp;
temp = map[changeX1][changeY1].type;
map[changeX1][changeY1].type = map[changeX2][changeY2].type;
map[changeX2][changeY2].type = temp;
Click3 = 0;
propsing = false;
return;
}
}
else
{
swap = true;
posX1 = row;
posY1 = col;
PlaySound("res/pao.wav", 0, SND_FILENAME | SND_ASYNC);
return;
}
}
}
}
if (Click2)
{
PlaySound("res/colorChange.wav", 0, SND_FILENAME | SND_ASYNC);
starLeave = starLeave - 25;
for (int i = ROWS; i >= 1; i--)
{
for (int j = 1; j <= COLS; j++)
{
if (map[i][j].exist)
{
map[i][j].type = rand() % difficulty + 1;
}
}
}
Click2 = 0;
propsing = false;
}
}
void move()
{
isMoving = false;
for (int i = ROWS; i >= 1; i--)
{
for (int j = 1; j <= COLS; j++)
{
struct block* p = &map[i][j];
int dx, dy;
for (int k = 0; k < 4; k++)
{
int x = off_x + (p->col - 1) * (blocks_size + gap_size);
int y = off_y + (p->row - 1) * (blocks_size + gap_size);
dx = p->x - x;
dy = p->y - y;
if (dx) p->x -= dx / abs(dx);
if (dy) p->y -= dy / abs(dy);
}
if (dx || dy) isMoving = true;
}
}
}
void check(int posX1, int posY1)
{
int i;
for (i = 0; i < 4; i++)
{
switch (i)
{
case 0:
if ((map[posX1][posY1].type == map[posX1 - 1][posY1].type) && (map[posX1 - 1][posY1].exist == 1) && (map[posX1 - 1][posY1].match == 0))
{
map[posX1 - 1][posY1].match = 1;
score = score + 10;
check(posX1 - 1, posY1);
}
break;
case 1:
if ((map[posX1][posY1].type == map[posX1 + 1][posY1].type) && (map[posX1 + 1][posY1].exist == 1) && (map[posX1 + 1][posY1].match == 0))
{
map[posX1 + 1][posY1].match = 1;
score = score + 10;
check(posX1 + 1, posY1);
}
break;
case 2:
if ((map[posX1][posY1].type == map[posX1][posY1 - 1].type) && (map[posX1][posY1 - 1].exist == 1) && (map[posX1][posY1 - 1].match == 0))
{
map[posX1][posY1 - 1].match = 1;
score = score + 10;
check(posX1, posY1 - 1);
}
break;
case 3:
if ((map[posX1][posY1].type == map[posX1][posY1 + 1].type) && (map[posX1][posY1 + 1].exist == 1) && (map[posX1][posY1 + 1].match == 0))
{
map[posX1][posY1 + 1].match = 1;
score = score + 10;
check(posX1, posY1 + 1);
}
break;
}
}
swap = false;
}
void xiaochu()
{
bool flag = false;
for (int i = 1; i <= ROWS; i++)
{
for (int j = 1; j <= COLS; j++)
{
if (map[i][j].match && map[i][j].tmd > 10 && map[i][j].exist)
{
swap = false;
isMoving = true;
if (map[i][j].tmd == 255)
{
flag = true;
}
map[i][j].tmd -= 25;
}
if (map[i][j].tmd <= 10)
{
map[i][j].tmd = 0;
map[i][j].exist = 0;
}
}
}
if (flag)
{
PlaySound("res/clear.wav", 0, SND_FILENAME | SND_ASYNC);
}
}
void updateGame1()
{
int i, j;
for (i = ROWS; i >= 1; i--)
{
for (j = 1; j <= COLS; j++)
{
if (map[i][j].match)
{
for (int k = i - 1; k >= 1; k--)
{
if (map[k][j].match == 0)
{
isMoving = true;
exchange(k, j, i, j);
break;
}
}
}
}
}
if (i == 1 && j == COLS)
{
isMoving = false;
}
}
void updateGame2(int i)
{
int k;
for (k = i + 1; k <= COLS; k++)
{
if (map[ROWS][k].exist)
{
break;
}
}
for (int j = ROWS; j >= 1; j--)
{
if (map[j][k].exist)
{
isMoving = true;
exchange(j, i, j, k);
}
}
}
void merge()
{
int i, j;
for (i = 1; i <= COLS; i++)
{