-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.c
More file actions
3355 lines (2880 loc) · 96 KB
/
test.c
File metadata and controls
3355 lines (2880 loc) · 96 KB
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
#pragma warning(disable:4996)
#pragma comment (lib, "winmm.lib")
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <Windows.h>
#include <time.h>
#include <conio.h>
#include <mmsystem.h>
#include <Digitalv.h>
#include "block.h"
// user controls
#define UP 72
#define DOWN 80
#define LEFT 75
#define RIGHT 77
#define ENTER 13
#define SPACE 32
#define R 114 // ultimate
#define ESC 27
#define GB 120 // x for go back
// size of gameboard
#define GBOARD_WIDTH 26
#define GBOARD_HEIGHT 18
// starting point of gameboard
#define GBOARD_ORIGIN_X 14
#define GBOARD_ORIGIN_Y 5
// size of storyboard
#define SBOARD_WIDTH 27
#define SBOARD_HEIGHT 18
// starting point of storyboard
#define SBOARD_ORIGIN_X 35
#define SBOARD_ORIGIN_Y 6
// size of ultimate board
#define UBOARD_WIDTH 7
#define UBOARD_HEIGHT 2
// starting point of ultimate board
#define UBOARD_ORIGIN_X 13
#define UBOARD_ORIGIN_Y 24
// size of fever board
#define FBOARD_WIDTH 7
#define FBOARD_HEIGHT 2
// starting point of fever board
#define FBOARD_ORIGIN_X 53
#define FBOARD_ORIGIN_Y 24
// size of controls board
#define CBOARD_WIDTH 8
#define CBOARD_HEIGHT 9
// starting point of controls board
#define CBOARD_ORIGIN_X 71
#define CBOARD_ORIGIN_Y 13
// size of story controls board
#define SCBOARD_WIDTH 8
#define SCBOARD_HEIGHT 9
// starting point of story controls board
#define SCBOARD_ORIGIN_X 37
#define SCBOARD_ORIGIN_Y 8
#define INFO_X 77
#define ITEM_Y 23
#define PAUSE_Y 17
#define TARGET_SCORE 50
typedef struct Moogi {
struct Moogi* front;
struct Moogi* back;
COORD position;
char direct;
} Moogi;
typedef struct _Item {
COORD pos;
int itemNo;
} Item, * pItem;
typedef struct Human {
int direct;
COORD position;
struct Human* next;
} Human;
typedef struct _Pet {
COORD pos;
} Pet;
int gameBoardInfo[GBOARD_HEIGHT + 1][GBOARD_WIDTH + 2];
int direction = 3;
int stage = 0;
int stageUnlock[5] = { 0, 0, 0, 0, 0 };
int stageBestScore[5] = { 0, 0, 0, 0, 0 };
int speed = 15;
int heart = 3;
int dragonBallCount = 0;
int itemCount = 0;
//FEVER related variables
int fever[5] = { 0,0,0,0,0 };
int feverStart = 0;
int feverScore = 0;
time_t feverWordCreateTime;
time_t feverStartTime;
COORD feverWordPos = { 0,0 };
Moogi* head = NULL;
Moogi* body = NULL;
Moogi* tail = NULL;
pItem item = NULL;
time_t itemCreationTime;
int length = 3;
int minLength = 2;
int maxLength = 40;
int minSpeed = 5;
int maxSpeed = 25;
int speedScore = 50;
int currentScore = 0;
Human* humanHead;
int humanNum = 0;
int moogiColor = 4; // 5가지 색상만 사용. 0→4(dark red), 1→6(dark yellow), 2→2(dark green), 3→9(blue), 4→15(white)
int dragonBallColor[5]; // 0빨 1노 2초 3파 4흰 고정, 어차피 위치랜덤돌릴거니까 얘 순서는 상관ㄴㄴ
COORD dragonBallPos[5]; // 빨노초파흰 순서대로 위치 저장. 알맞은 색깔의 여의주를 먹으면 나머지들은 없애줘야하기때문..하..
int petGauge = 5;
int petScore = 0;
Pet* pet = NULL;
time_t petCreationTime;
COORD wormholePos[2];
int stage5InPlay = 0;
int turnOnAndOff = 1;
int stage5map = 0;
COORD stage5DragonBallPos[5];
int stage5DragonBallNum = 0;
time_t stage5ShowDragonBall[5];
int humanAttack = 0;
void reset();
void resetGameBoardInfo();
// stages
void stage1();
void stage2();
void stage3();
void stage4();
void stage5();
// Map related functions;
void gotoxycol(int x, int y, int col, char* s);
void introScreen();
void startScreen();
void story();
void tutorial();
void selectStage();
void drawBoard();
void drawUlt();
void drawFever();
void printStage();
void printScore();
void printHighscore();
void drawLife();
void drawControls();
void drawKeys();
void clearScreen();
void clearControls();
void stageClr();
void ending();
void gameOver();
// console related functions
void console();
void setCurrentCursorPos(int x, int y);
COORD getCurrentCursorPos();
void removeCursor();
void gotoxy(int x, int y, char* ch);
void setTextColor(int colorNum);
void initGameBoardInfo();
void drawBoard();
void initMoogi();
void addBody();
void deleteBody();
void speedUp();
void speedDown();
void createItem();
void deleteItem();
void getHeart();
void dragonBallBomb();
void getPet();
void usePet();
void petMove();
void getItemOfPet();
void moogiSwitch();
void waitToRecover();
void inPlayKeyInput();
void shiftUp();
void shiftDown();
void shiftLeft();
void shiftRight();
void pausePlay();
int detectCollision(int currentPosX, int currentPosY);
COORD nextHeadPos();
void drawHead(COORD headPos);
void eraseTail();
Moogi* getNode(Moogi* front, Moogi* back, COORD position);
int moogiMove();
void getSomething();
void humanMove();
void countScore();
void getBestScore();
void setBestScore(int score);
void saveBestScore();
int isGameOver();
void getItem();
void addDragonBall();
void showDragonBall(int arrX, int arrY);
void addHuman();
void addBlock();
void setTextColor_rygbw(int colorNum);
void changeMoogiColor();
void changeMoogiBodyColor();
void setDragonBallColor();
void setDragonBallPos();
void showColorDragonBall(int x, int y, int color);
void deleteDragonBall();
void createFever();
void deleteFeverWord();
void getFever();
int isFever();
void fillFever();
void removeFever();
void wormhole();
void isHumanAttack();
int isIn(int x, int y);
int nearTheHead(int x, int y);
void showTurnOnArea();
void addGameBoardInfo();
void showDragonBallPos();
// 브금 관련
MCI_OPEN_PARMS openOpeningBgm; // dwID1
MCI_PLAY_PARMS playOpeningBgm;
MCI_OPEN_PARMS openPlayingBgm; // dwID2
MCI_PLAY_PARMS playPlayingBgm;
MCI_OPEN_PARMS openSelectSound; // dwID3
MCI_PLAY_PARMS playSelectSound;
MCI_OPEN_PARMS openGetSound; // dwID4
MCI_PLAY_PARMS playGetSound;
MCI_OPEN_PARMS openCollisionSound; // dwID5
MCI_PLAY_PARMS playCollisionSound;
MCI_OPEN_PARMS openClearSound; // dwID6
MCI_PLAY_PARMS playClearSound;
MCI_OPEN_PARMS openGameoverSound; // dwID7
MCI_PLAY_PARMS playGameoverSound;
MCI_OPEN_PARMS openTypeSound; // dwID8
MCI_PLAY_PARMS playTypeSound;
MCI_OPEN_PARMS openThunderSound; // dwID9
MCI_PLAY_PARMS playThunderSound;
int dwID1, dwID2, dwID3, dwID4, dwID5, dwID6, dwID7, dwID8, dwID9;
void openingBGM(int play);
void playingBGM(int play);
void selectSound();
void getSound();
void collisionSound();
void clearSound();
void gameoverSound();
void typeSound();
void thunderSound();
void printMatrix();
int main() {
console();
removeCursor();
introScreen();
startScreen();
getBestScore();
while (1)
{
if (stage != 0 && stage != 5 && stageUnlock[stage] == 1)
{
stageUnlock[stage] = 2;
stage++;
}
else
{
system("cls");
selectStage();
}
system("cls");
switch (stage)
{
case 1:
clearScreen();
reset();
stage1();
break;
case 2:
clearScreen();
reset();
stage2();
break;
case 3:
clearScreen();
reset();
stage3();
break;
case 4:
clearScreen();
reset();
stage4();
break;
case 5:
clearScreen();
reset();
stage5();
break;
default:
break;
}
}
getch();
return 0;
}
void stage1() {
drawBoard();
srand((unsigned int)time(NULL));
initMoogi();
addDragonBall();
createItem();
int key = 0;
playingBGM(0);
while (1) {
if (isGameOver()) break;
if (key == ENTER) break;
while (1) {
if (moogiMove() == 0) break;
if (stageBestScore[0] < TARGET_SCORE && currentScore >= TARGET_SCORE)
{
stageUnlock[1] = 1;
playingBGM(1);
clearScreen();
stageClr();
while (1) {
if (_kbhit()) {
key = _getch();
if (key == ENTER) break;
}
}
}
if (key == ENTER) break;
inPlayKeyInput();
}
}
setBestScore(currentScore);
saveBestScore();
if (key == ENTER) return;
playingBGM(1);
gameOver();
}
void stage2() {
drawBoard();
srand((unsigned int)time(NULL));
initMoogi();
addDragonBall();
createItem();
humanHead = (Human*)malloc(sizeof(Human));
humanHead->next = NULL;
int key = 0;
playingBGM(0);
while (1) {
if (isGameOver()) break;
if (key == ENTER) break;
while (1) {
if (moogiMove() == 0) break;
//if (humanAttack) break;
if (stageBestScore[1] < TARGET_SCORE && currentScore >= TARGET_SCORE)
{
stageUnlock[2] = 1;
playingBGM(1);
clearScreen();
stageClr();
while (1) {
if (_kbhit()) {
key = _getch();
if (key == ENTER) break;
}
}
}
if (key == ENTER) break;
inPlayKeyInput();
}
}
setBestScore(currentScore);
saveBestScore();
setTextColor(4);
if (key == ENTER) return;
playingBGM(1);
gameOver();
}
void stage3() {
drawBoard();
srand((unsigned int)time(NULL));
setDragonBallColor();
setDragonBallPos();
initMoogi();
createItem();
addDragonBall();
int key = 0;
playingBGM(0);
while (1) {
if (isGameOver()) break;
if (key == ENTER) break;
while (1) {
if (moogiMove() == 0) break;
if (stageBestScore[2] < TARGET_SCORE && currentScore >= TARGET_SCORE)
{
stageUnlock[3] = 1;
playingBGM(1);
clearScreen();
stageClr();
while (1) {
if (_kbhit()) {
key = _getch();
if (key == ENTER) break;
}
}
}
if (key == ENTER) break;
//printMatrix();
inPlayKeyInput();
}
}
setBestScore(currentScore);
saveBestScore();
if (key == ENTER) return;
playingBGM(1);
gameOver();
}
void stage4() {
drawBoard();
srand((unsigned int)time(NULL));
initMoogi();
addDragonBall();
createItem();
int key = 0;
playingBGM(0);
while (1) {
if (isGameOver()) break;
if (key == ENTER) break;
while (1) {
if (moogiMove() == 0) break;
if (stageBestScore[3] < TARGET_SCORE && currentScore >= TARGET_SCORE)
{
stageUnlock[4] = 1;
playingBGM(1);
clearScreen();
stageClr();
while (1) {
if (_kbhit()) {
key = _getch();
if (key == ENTER) break;
}
}
}
if (key == ENTER) break;
inPlayKeyInput();
}
}
setBestScore(currentScore);
saveBestScore();
if (key == ENTER) return;
playingBGM(1);
gameOver();
}
void stage5()
{
drawBoard();
srand((unsigned int)time(NULL));
initMoogi();
stage5InPlay = 1;
addGameBoardInfo();
addDragonBall();
createItem();
int key = 0;
stage5map = rand() % 4;
playingBGM(0);
while (1)
{
if (isGameOver()) break;
if (key == ENTER) break;
while (1)
{
showTurnOnArea();
showDragonBallPos();
if (moogiMove() == 0) break;
if (stageBestScore[4] < TARGET_SCORE && currentScore >= TARGET_SCORE)
{
stage5InPlay = 0;
//stageUnlock[4] = 1;
playingBGM(1);
clearScreen();
stageClr();
while (1)
{
if (_kbhit())
{
key = _getch();
if (key == ENTER) {
system("cls");
ending();
break;
}
}
}
}
if (key == ENTER) break;
inPlayKeyInput();
//turnOn();
}
}
stage5InPlay = 0;
setBestScore(currentScore);
saveBestScore();
if (key == ENTER) return;
playingBGM(1);
gameOver();
}
void printMatrix()
{
for (int i = 0; i < GBOARD_HEIGHT + 1; i++)
{
setCurrentCursorPos(INFO_X, PAUSE_Y + 2 + i);
for (int j = 0; j < GBOARD_WIDTH + 2; j++)
{
if (!gameBoardInfo[i][j]) printf(" ");
else if (tail->position.X == j * 2 + GBOARD_ORIGIN_X && tail->position.Y == i + GBOARD_ORIGIN_Y)
printf("6 ");
else printf("%d ", gameBoardInfo[i][j]);
}
}
}
/*-----------------------------------------------------------------------------------------*/
void console() { // set console size
system("mode con:cols=125 lines=33"); // 125 33
}
void setCurrentCursorPos(int x, int y) { // set current cursor position
COORD pos = { x, y };
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), pos);
}
COORD getCurrentCursorPos() { // get current cursor position
COORD curPos;
CONSOLE_SCREEN_BUFFER_INFO curInfo;
GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &curInfo);
curPos.X = curInfo.dwCursorPosition.X;
curPos.Y = curInfo.dwCursorPosition.Y;
return curPos;
}
void removeCursor() { // remove cursor blinking
CONSOLE_CURSOR_INFO curInfo;
GetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE), &curInfo);
curInfo.bVisible = 0;
SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE), &curInfo);
}
void gotoxy(int x, int y, char* s) {
if (stage5InPlay && !nearTheHead(x, y) && isIn(x, y) && !isFever()) return;
COORD pos = { x,y };
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), pos);
printf("%s", s);
}
void setTextColor(int colorNum) {
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), colorNum);
}
void gotoxycol(int x, int y, int col, char* s) {
if (stage5InPlay && !nearTheHead(x, y) && isIn(x, y) && !isFever()) return;
COORD pos = { x,y };
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), pos);
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), col);
printf("%s", s);
}
// 0(Black) 1(Dark Blue) 2(Dark Green) 3(Dark Sky Blue) 4(Dark Red)
// 5(Dark Purple) 6(Dark Yellow) 7(Gray) 8(Dark Gray) 9(Blue)
// 10(Green) 11(Sky Blue) 12(Red) 13(Purple) 14(Yellow) 15(White)
/*-----------------------------------------------------------------------------------------*/
void introScreen() {
openingBGM(0);
gotoxycol(8, 10, 14, "┏━━━┓┏┓┏┓┏┓━━━┏┓━━━━━┏┓━━━━━━┏━━━┓━━━━━━━━━━━━━━━━━━━━");
gotoxycol(8, 11, 14, "┃┏━┓┃┃┃┃┃┃┃━━┏┛┗┓━━━━┃┃━━━━━━┗┓┏┓┃━━━━━━━━━━━━━━━━━━━━");
gotoxycol(8, 12, 14, "┃┗━━┓┃┃┃┃┃┃┏┓┗┓┏┛┏━━┓┃┗━┓━━━━━┃┃┃┃┏━┓┏━━┓━┏━━┓┏━━┓┏━┓━");
gotoxycol(8, 13, 14, "┗━━┓┃┃┗┛┗┛┃┣┫━┃┃━┃┏━┛┃┏┓┃━━━━━┃┃┃┃┃┏┛┗━┓┃━┃┏┓┃┃┏┓┃┃┏┓┓");
gotoxycol(8, 14, 14, "┃┗━┛┃┗┓┏┓┏┛┃┃━┃┗┓┃┗━┓┃┃┃┃━━━━┏┛┗┛┃┃┃━┃┗┛┗┓┃┗┛┃┃┗┛┃┃┃┃┃");
gotoxycol(8, 15, 14, "┗━━━┛━┗┛┗┛━┗┛━┗━┛┗━━┛┗┛┗┛━━━━┗━━━┛┗┛━┗━━━┛┗━┓┃┗━━┛┗┛┗┛");
gotoxycol(8, 16, 14, "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┏━┛┃━━━━━━━━");
gotoxycol(8, 17, 14, "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┗━━┛━━━━━━━━");
while (1) {
if (kbhit()) break;
gotoxycol(47, 22, 14, "[ Press any key to start ]");
Sleep(700);
gotoxycol(47, 22, 14, " ");
Sleep(100);
}
//getch(); openingBGM이 입력을 한번 받는건지 selectStage에서 한번 먹히길래 이걸 뺌
openingBGM(1);
system("cls");
}
void startScreen() {
gotoxycol(48, 10, 14, "Press ENTER to choose mode: ");
gotoxycol(53, 13, 14, "▶ ┏STORY");
gotoxycol(54, 15, 14, "┏TUTORIAL");
gotoxycol(54, 17, 14, "┏PLAY");
int key = 0, count = 0;
int mode = 0;
while (1) {
if (_kbhit()) {
key = _getch();
if (key == ENTER) {
selectSound();
mode = count;
}
else if (key == UP) count--;
else if (key == DOWN) count++;
if (count == 0) count = 1;
if (count == 4) count = 1;
switch (count) {
case 1:
gotoxycol(53, 13, 14, "▶ ┏STORY");
gotoxycol(54, 15, 14, "┏TUTORIAL ");
gotoxycol(54, 17, 14, "┏PLAY ");
break;
case 2:
gotoxycol(53, 15, 14, "▶ ┏TUTORIAL");
gotoxycol(54, 13, 14, "┏STORY ");
gotoxycol(54, 17, 14, "┏PLAY ");
break;
case 3:
gotoxycol(53, 17, 14, "▶ ┏PLAY ");
gotoxycol(54, 13, 14, "┏STORY ");
gotoxycol(54, 15, 14, "┏TUTORIAL ");
break;
default:
break;
}
}
switch (mode) {
case 1:
gotoxycol(53, 13, 2, "▶ ┏STORY");
Sleep(600);
for (int i = 0; i < 7; i++) {
gotoxycol(53, 13, 2, "▶ ┏STORY");
Sleep(100);
gotoxycol(53, 13, 15, "▶ ┏STORY");
Sleep(100);
}
story();
key = 0, count = 0, mode = 0;
break;
case 2:
gotoxycol(53, 15, 2, "▶ ┏TUTORIAL");
Sleep(600);
for (int i = 0; i < 7; i++) {
gotoxycol(53, 15, 2, "▶ ┏TUTORIAL");
Sleep(100);
gotoxycol(53, 15, 15, "▶ ┏TUTORIAL");
Sleep(100);
}
tutorial();
key = 0, count = 0, mode = 0;
break;
case 3:
gotoxycol(53, 17, 2, "▶ ┏PLAY");
Sleep(600);
for (int i = 0; i < 7; i++) {
gotoxycol(53, 17, 2, "▶ ┏PLAY");
Sleep(100);
gotoxycol(53, 17, 15, "▶ ┏PLAY");
Sleep(100);
}
return;
default:
break;
}
}
}
void story() {
system("cls");
gotoxycol(37, 5, 10, " /^|/^|");
gotoxycol(37, 6, 10, " _|_ _| | )");
gotoxycol(49, 6, 15, "0 0");
gotoxycol(37, 7, 10, " /~ |_/ )");
gotoxycol(37, 7, 12, "V");
gotoxycol(37, 8, 10, " |__________/ )");
gotoxycol(37, 8, 12, "|____");
gotoxycol(37, 9, 10, " /_______ )");
gotoxycol(37, 10, 10, " `'/ )");
gotoxycol(37, 11, 10, " / / \\");
gotoxycol(37, 12, 10, " / / \\\\");
gotoxycol(37, 13, 10, " / / \\ \\");
gotoxycol(37, 14, 10, " / / _----_ \\ \\");
gotoxycol(37, 15, 10, " / / _-~ ~-_ | |");
gotoxycol(37, 16, 10, " ( ( _-~ _--_ ~-_ _/ |");
gotoxycol(37, 17, 10, " ( ~-____-~ _-~ ~-_ ~-_-~ /");
gotoxycol(37, 18, 10, " ~-_ _-~ ~-_ _-~");
gotoxycol(37, 19, 10, " ~--______-~ ~-___-~");
char story[105] = "수세기 전, 인간과 이무기가 공존하던 시대가 있었다. 그러나 이무기들은 21살이 되는 해에 여의주를 모아 용이";
char story1[105] = "되어 승천해야 했는데, 주인공 '이무기'는 이 특별한 날을 맞아 여의주를 찾아 떠나는 모험을 시작한다. 하지만";
char story2[50] = "다른 이무기들과는 달리 순탄치만은 않아 보이는데…";
char story3[57] = "...과연 이무기는 무사히 여의주를 모아 용이 될 수 있을까?";
int i;
setTextColor(14);
setCurrentCursorPos(10, 23);
typeSound();
for (i = 0; i < 105; i++) {
printf("%c", story[i]);
Sleep(20);
}
setCurrentCursorPos(10, 25);
typeSound();
for (i = 0; i < 105; i++) {
printf("%c", story1[i]);
Sleep(20);
}
setCurrentCursorPos(10, 27);
for (i = 0; i < 50; i++) {
printf("%c", story2[i]);
Sleep(20);
}
Sleep(2000);
setCurrentCursorPos(10, 23);
for (i = 0; i < 105; i++) printf(" ");
setCurrentCursorPos(10, 25);
for (i = 0; i < 105; i++) printf(" ");
setCurrentCursorPos(10, 27);
for (i = 0; i < 50; i++) {
printf(" ");
}
typeSound();
Sleep(40);
setCurrentCursorPos(36, 25);
for (int i = 0; i < 57; i++) {
printf("%c", story3[i]);
Sleep(70);
}
int key = 0;
while (1) {
if (kbhit()) {
key = getch();
if (key == GB) {
system("cls");
gotoxycol(48, 10, 14, "Press ENTER to choose mode: ");
gotoxycol(53, 13, 14, "▶ ┏STORY");
gotoxycol(54, 15, 14, "┏TUTORIAL");
gotoxycol(54, 17, 14, "┏PLAY");
break;
}
}
gotoxycol(70, 29, 14, "[ Press X to go back ]");
Sleep(700);
gotoxy(70, 29, " ");
Sleep(100);
}
}
void tutorial() {
system("cls");
for (int y = 0; y <= SBOARD_HEIGHT; y++) {
if (y == 0) gotoxycol(SBOARD_ORIGIN_X, SBOARD_ORIGIN_Y + y, 14, "┏");
else if (y == SBOARD_HEIGHT) gotoxycol(SBOARD_ORIGIN_X, SBOARD_ORIGIN_Y + y, 14, "┗");
else gotoxycol(SBOARD_ORIGIN_X, SBOARD_ORIGIN_Y + y, 14, "┃");
if (y == 0) gotoxycol(SBOARD_ORIGIN_X + (SBOARD_WIDTH + 1) * 2, SBOARD_ORIGIN_Y + y, 14, "┓");
else if (y == SBOARD_HEIGHT) gotoxycol(SBOARD_ORIGIN_X + (SBOARD_WIDTH + 1) * 2, SBOARD_ORIGIN_Y + y, 14, "┛");
else gotoxycol(SBOARD_ORIGIN_X + (SBOARD_WIDTH + 1) * 2, SBOARD_ORIGIN_Y + y, 14, "┃");
}
for (int x = 1; x < SBOARD_WIDTH + 1; x++) {
gotoxycol(SBOARD_ORIGIN_X + x * 2, SBOARD_ORIGIN_Y, 14, "━");
gotoxycol(SBOARD_ORIGIN_X + x * 2, SBOARD_ORIGIN_Y + SBOARD_HEIGHT, 14, "━");
}
for (int y = 0; y <= SCBOARD_HEIGHT; y++) {
if (y == 0) gotoxycol(SCBOARD_ORIGIN_X, SCBOARD_ORIGIN_Y + y, 15, "┏");
else if (y == SCBOARD_HEIGHT) gotoxycol(SCBOARD_ORIGIN_X, SCBOARD_ORIGIN_Y + y, 15, "┗");
else gotoxycol(SCBOARD_ORIGIN_X, SCBOARD_ORIGIN_Y + y, 15, "┃");
if (y == 0) gotoxycol(SCBOARD_ORIGIN_X + (SCBOARD_WIDTH + 1) * 2, SCBOARD_ORIGIN_Y + y, 15, "┓");
else if (y == SCBOARD_HEIGHT) gotoxycol(SCBOARD_ORIGIN_X + (SCBOARD_WIDTH + 1) * 2, SCBOARD_ORIGIN_Y + y, 15, "┛");
else gotoxycol(SCBOARD_ORIGIN_X + (SCBOARD_WIDTH + 1) * 2, SCBOARD_ORIGIN_Y + y, 15, "┃");
}
for (int x = 1; x < SCBOARD_WIDTH + 1; x++) {
gotoxycol(SCBOARD_ORIGIN_X + x * 2, SCBOARD_ORIGIN_Y, 15, "━");
gotoxycol(SCBOARD_ORIGIN_X + x * 2, SCBOARD_ORIGIN_Y + SCBOARD_HEIGHT, 15, "━");
}
gotoxycol(43, 9, 8, "CONTROLS");
gotoxycol(46, 11, 10, "↑");
gotoxycol(44, 12, 10, "← →");
gotoxycol(46, 13, 10, "↓");
gotoxycol(39, 15, 7, "[ ] to use PET");
gotoxycol(40, 15, 10, "R");
gotoxycol(39, 16, 7, "[ ] to STOP");
gotoxycol(40, 16, 10, "SPACE");
gotoxycol(59, 9, 8, "ITEMS");
gotoxycol(59, 11, 11, "▲ : GOOD");
gotoxycol(59, 13, 15, "길이↓, 속도↓, 생명↑");
gotoxycol(59, 15, 15, "여의주 폭탄!, 궁 게이지↑");
gotoxycol(59, 17, 12, "▼: BAD");
gotoxycol(59, 19, 15, "길이↑, 속도↑");
int key = 0;
while (1) {
if (kbhit()) {
key = getch();
if (key == GB) {
system("cls");
startScreen();
break;
}
}
gotoxycol(38, 22, 14, "[ Press X to go back ]");
Sleep(700);
gotoxy(38, 22, " ");
Sleep(100);
}
}
void selectStage() {
getBestScore();
gotoxycol(48, 8, 14, "Press stage number to play: ");
gotoxycol(49, 11, 14, "▶ ┏Stage 1: Classic");
if (stageBestScore[0] < TARGET_SCORE) gotoxycol(50, 13, 8, "┏Stage 2: Off The Wall\t[ LOCKED ]");
else gotoxycol(50, 13, 14, "┏Stage 2: Off The Wall\t");
if (stageBestScore[1] < TARGET_SCORE) gotoxycol(50, 15, 8, "┏Stage 3: 이무지개 \t[ LOCKED ]");
else gotoxycol(50, 15, 14, "┏Stage 3: 이무지개\t");
if (stageBestScore[2] < TARGET_SCORE) gotoxycol(50, 17, 8, "┏Stage 4: 순간이무기동\t[ LOCKED ]");
else gotoxycol(50, 17, 14, "┏Stage 4: 순간이무기동\t");
if (stageBestScore[3] < TARGET_SCORE) gotoxycol(50, 19, 8, "┏Stage 5: 반짝이무기 \t[ LOCKED ]");
else gotoxycol(50, 19, 14, "┏Stage 5: 반짝이무기\t");
int key = 0, count = 0;
stage = 0;
while (1) {
if (_kbhit()) {
key = _getch();
if (key == ENTER) {
selectSound();
stage = count;
}
else if (key == UP) {
count--;
}
else if (key == DOWN) {
count++;
}
if (stageBestScore[3] >= TARGET_SCORE) if (count == 0) count = 1;
if (count == 0) count = 1;
if (count == 6) count = 1;
switch (count) {
case 1:
gotoxycol(49, 11, 14, "▶ ┏Stage 1: Classic");
if (stageBestScore[0] < TARGET_SCORE) gotoxycol(50, 13, 8, "┏Stage 2: Off The Wall\t[ LOCKED ]");
else gotoxycol(50, 13, 14, "┏Stage 2: Off The Wall\t");
if (stageBestScore[3] < TARGET_SCORE) gotoxycol(50, 19, 8, "┏Stage 5: 반짝이무기 \t[ LOCKED ]");
else gotoxycol(50, 19, 14, "┏Stage 5: 반짝이무기\t");
break;
case 2:
if (stageBestScore[0] < TARGET_SCORE) {
count = 1;
break;
gotoxycol(50, 13, 8, "▶ ┏Stage 2: Off The Wall\t[ LOCKED ]");