-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinterface.h
More file actions
732 lines (638 loc) · 24 KB
/
interface.h
File metadata and controls
732 lines (638 loc) · 24 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
#ifndef INTERFACE_H
#define INTERFACE_H
#include <stdio.h>
#include <stdlib.h>
#include <termios.h>
#include <unistd.h>
#include <ncurses.h>
#include <locale.h>
#include <vector>
#include <string>
#include <algorithm>
#include <cctype>
#include "GameManger.h"
#include "SentenceManager.h"
#include "ItemBox.h"
// 기본 화면 인터페이스
class Screen
{
public:
virtual ~Screen() {}
virtual void UpdateScreen() = 0;
virtual void resizeScreen() = 0;
virtual void shapeScreen() = 0;
};
// -------------------------------------------------------
// 🎮 게임 플레이 화면 (PlayScreen)
// -------------------------------------------------------
class PlayScreen : public Screen
{
private:
int currentLevel;
int gameWidth;
int gameHeight;
bool gameRunning;
int gameAreaWidth; // 게임 영역 폭 (왼쪽)
int scoreAreaWidth; // 점수판 영역 폭 (오른쪽)
GameManager *gameManager; // 게임 상태 관리
SentenceManager *sentenceManager; // 단어 및 문장 관리
// 눈사람 완성 애니메이션 관련 변수 추가
bool snowmanCompleted;
time_t snowmanCompletedTime;
bool showCompletedSnowman;
// =========================================================
// 🎨 [Visual Artist] 화면 그리기 도우미 함수들 (Private)
// =========================================================
// 1. 전체 테두리 및 구획 나누기 (안전한 ASCII 문자 버전)
void drawFrame()
{
attron(COLOR_PAIR(1));
// 상단 가로선 (+와 -로 그리기)
mvprintw(0, 0, "+");
for (int i = 1; i < gameAreaWidth; i++) mvprintw(0, i, "-");
mvprintw(0, gameAreaWidth, "+");
for (int i = gameAreaWidth + 1; i < gameWidth - 1; i++) mvprintw(0, i, "-");
mvprintw(0, gameWidth - 1, "+");
// 상단 제목 영역
mvprintw(1, 0, "|");
mvprintw(1, 2, "SNOW MAN GAME - Level %d", currentLevel);
mvprintw(1, gameAreaWidth, "|");
mvprintw(1, gameAreaWidth + 2, "Let's Build a Snowman!");
mvprintw(1, gameWidth - 1, "|");
// 중간 가로선
mvprintw(2, 0, "+");
for (int i = 1; i < gameAreaWidth; i++) mvprintw(2, i, "-");
mvprintw(2, gameAreaWidth, "+");
for (int i = gameAreaWidth + 1; i < gameWidth - 1; i++) mvprintw(2, i, "-");
mvprintw(2, gameWidth - 1, "+");
// 세로선 그리기 (|로 그리기)
for (int row = 3; row < gameHeight - 2; row++)
{
mvprintw(row, 0, "|"); // 왼쪽 끝
mvprintw(row, gameAreaWidth, "|"); // 중간 구분선
mvprintw(row, gameWidth - 1, "|"); // 오른쪽 끝
}
// 하단 가로선
mvprintw(gameHeight - 2, 0, "+");
for (int i = 1; i < gameAreaWidth; i++) mvprintw(gameHeight - 2, i, "-");
mvprintw(gameHeight - 2, gameAreaWidth, "+");
for (int i = gameAreaWidth + 1; i < gameWidth - 1; i++) mvprintw(gameHeight - 2, i, "-");
mvprintw(gameHeight - 2, gameWidth - 1, "+");
attroff(COLOR_PAIR(1));
}
// 2. 큰 눈사람 그리기 (옵션 2: 뚱뚱이 찹쌀떡 스타일)
void drawBigSnowman(int y, int x, bool isComplete)
{
if (isComplete)
{
attron(COLOR_PAIR(5) | A_BOLD);
// 얼굴 (납작하고 귀여움)
mvprintw(y + 3, x, " .-------. ");
mvprintw(y + 4, x, " ( ^ _ ^ ) "); // 찡긋
// 몸통 (푸짐함)
mvprintw(y + 5, x, " .--' '--. ");
mvprintw(y + 6, x, " _( : )_ "); // 나뭇가지 팔 추가!
mvprintw(y + 7, x, "(_____________________)");
attroff(COLOR_PAIR(5) | A_BOLD);
}
else
{
// 동그랗게 녹은 모습
attron(COLOR_PAIR(5));
mvprintw(y + 6, x, " . . . ");
mvprintw(y + 7, x, " ( x _ x ) ");
mvprintw(y + 8, x, " (___________) ");
attroff(COLOR_PAIR(5));
}
}
// 3. 작은 눈사람 점수판 (2단 미니 스타일)
void drawLifeSnowmen(int y, int x, int count)
{
attron(COLOR_PAIR(2)); // YELLOW
mvprintw(y, x+6, "[ COLLECTION ]");
int maxSnowmen = 8;
int displayCount = std::min(count, maxSnowmen);
for (int i = 0; i < maxSnowmen; i++)
{
// 2줄 간격(padding)을 활용해 머리와 몸통을 따로 그림
int drawY = y + 2 + (i / 4) * 3; // 간격을 3칸으로 살짝 늘림
int drawX = x + (i % 4) * 7;
if (i < displayCount)
{
attron(A_BOLD);
mvprintw(drawY, drawX, " o "); // 머리
mvprintw(drawY + 1, drawX, " (:) "); // 몸통
attroff(A_BOLD);
}
else
{
// 빈 자리 표시
mvprintw(drawY, drawX, " . ");
mvprintw(drawY + 1, drawX, " . ");
}
}
attroff(COLOR_PAIR(2));
}
// 4. 텍스트 정보 출력 (큰 눈사람 위치 미세 조정 버전)
void drawInfoPanel()
{
attron(COLOR_PAIR(5));
// 오른쪽 패널의 중심점 계산
int rightPanelStart = gameAreaWidth;
int rightPanelWidth = gameWidth - gameAreaWidth;
int centerX = rightPanelStart + (rightPanelWidth / 2);
// -----------------------------------------------------------
// 1. 상단: TIME & ITEM
// -----------------------------------------------------------
// 시간 박스
mvprintw(4, centerX - 11, "+--------------------+");
mvprintw(5, centerX - 11, "| TIME REMAINING |");
attron(A_BOLD);
std::string timeStr = gameManager->getFormattedTime();
int timeX = centerX - (timeStr.length() / 2);
mvprintw(6, centerX - 11, "| |");
mvprintw(6, timeX, "%s", timeStr.c_str());
attroff(A_BOLD);
mvprintw(7, centerX - 11, "+--------------------+");
// 아이템 박스
attron(COLOR_PAIR(4) | A_BOLD);
mvprintw(9, centerX - 11, "+--------------------+");
std::string itemMsg;
if (gameManager->shouldDisplayItemEffect()) {
itemMsg = gameManager->getLastItemEffectMessage();
} else {
itemMsg = "ITEM EFFECT READY";
}
int msgX = centerX - (itemMsg.length() / 2);
mvprintw(10, centerX - 11, "| |");
mvprintw(10, msgX, "%s", itemMsg.c_str());
mvprintw(11, centerX - 11, "+--------------------+");
attroff(COLOR_PAIR(4) | A_BOLD);
// -----------------------------------------------------------
// 2. 중단: GAME INFO
// -----------------------------------------------------------
const char* divider = "==========================";
int divX = centerX - 13;
mvprintw(13, divX, "%s", divider);
mvprintw(14, centerX - 5, "GAME INFO");
mvprintw(15, divX, "%s", divider);
mvprintw(16, divX + 2, "LEVEL: %-2d SCORE: %-4d", currentLevel, gameManager->getTotalScore());
if (showCompletedSnowman)
{
attron(COLOR_PAIR(2) | A_BOLD);
std::string msg = " SNOWMAN COMPLETE! ";
mvprintw(17, divX + 1, "%s", msg.c_str());
attroff(COLOR_PAIR(2) | A_BOLD);
}
else if (gameManager->isWaitingForCompletion())
{
attron(COLOR_PAIR(2) | A_BOLD);
std::string msg = " COMPLETE SENTENCE! ";
mvprintw(17, divX + 1, "%s", msg.c_str());
attroff(COLOR_PAIR(2) | A_BOLD);
}
else
{
mvprintw(17, divX + 2, "WORDS: %d/8 MATCH: %d/8",
gameManager->getCurrentWordIndex(), sentenceManager->getCorrectMatches());
}
mvprintw(18, divX, "%s", divider);
attroff(COLOR_PAIR(5));
// -----------------------------------------------------------
// 3. 하단: Collection & Big Snowman (위치 미세 조정)
// -----------------------------------------------------------
// [Collection 중앙 정렬]
int collectionX = centerX - 13;
int collectionY = 21;
drawLifeSnowmen(collectionY, collectionX, gameManager->getCollectedSnowmen());
// [Big Snowman 왼쪽으로 조금 더 이동]
// 기존: centerX - 8 -> 수정: centerX - 10 (2칸 더 왼쪽으로)
int snowmanX = centerX - 10;
int snowmanY = 27; // 높이 유지
drawBigSnowman(snowmanY, snowmanX, showCompletedSnowman);
// -----------------------------------------------------------
// 4. 최하단: 입력창
// -----------------------------------------------------------
int inputStartY = 37;
attron(COLOR_PAIR(3));
std::string inputTitle = "======== WORD INPUT ========";
mvprintw(inputStartY, centerX - (inputTitle.length() / 2), "%s", inputTitle.c_str());
const auto &userInputs = sentenceManager->getInputHandler()->getUserInputs();
int currentIdx = sentenceManager->getInputHandler()->getCurrentInputIndex();
int inputLineX = centerX - 10;
for (int i = 0; i < 8; i++)
{
if (i == currentIdx && !showCompletedSnowman)
{
attron(COLOR_PAIR(2) | A_BOLD);
mvprintw(inputStartY + 2 + i, inputLineX, "[%d] > %s_",
i + 1, userInputs[i].c_str());
attroff(COLOR_PAIR(2) | A_BOLD);
}
else
{
attron(COLOR_PAIR(3));
mvprintw(inputStartY + 2 + i, inputLineX, "[%d] %s",
i + 1, userInputs[i].c_str());
attroff(COLOR_PAIR(3));
}
}
// 컨트롤 가이드
int guideY = gameHeight - 2;
std::string guide = "TAB: Next | ESC: Menu | Type 'random' for item";
mvprintw(guideY, centerX - (guide.length()/2), "%s", guide.c_str());
attroff(COLOR_PAIR(3));
// 상태 메시지
if (gameManager->isTimeUp())
{
attron(COLOR_PAIR(4) | A_BOLD);
mvprintw(gameHeight - 1, 2, "TIME UP! Score: %d | Press ESC", gameManager->getTotalScore());
attroff(COLOR_PAIR(4) | A_BOLD);
}
else if (!gameManager->isGameRunning() && gameRunning)
{
attron(COLOR_PAIR(2) | A_BOLD);
mvprintw(gameHeight - 1, 2, "Complete! Score: %d | Press ESC", gameManager->getTotalScore());
attroff(COLOR_PAIR(2) | A_BOLD);
}
else
{
mvprintw(gameHeight - 1, 2, "Running... | %s | Score: %d",
gameManager->getFormattedTime().c_str(), gameManager->getTotalScore());
}
refresh();
}
// 5. 입력창 그리기 (drawInfoPanel에서 통합해서 사용 안 함 - 중복 방지)
void drawInputArea()
{
// drawInfoPanel에서 처리하므로 비워둠 or 삭제 가능
}
// 6. 배경 효과
void drawBackgroundEffect()
{
attron(COLOR_PAIR(3));
// 일단은 장식용 눈송이만 찍어둡니다.
// 나중에 sentenceManager->getFallingObjects() 로직이 생기면 교체하세요!
mvprintw(5, 10, "*");
mvprintw(8, 25, ".");
mvprintw(12, 15, "*");
mvprintw(15, 40, "*");
mvprintw(20, 5, ".");
mvprintw(10, 50, "~");
mvprintw(22, 55, "*");
attroff(COLOR_PAIR(3));
}
public:
PlayScreen(int level) : currentLevel(level), gameWidth(120), gameHeight(50), gameRunning(true),
gameAreaWidth(60), scoreAreaWidth(58),
snowmanCompleted(false), snowmanCompletedTime(0), showCompletedSnowman(false)
{
setlocale(LC_ALL, "");
initscr();
noecho();
cbreak();
keypad(stdscr, TRUE);
curs_set(0);
if (has_colors())
{
start_color();
init_pair(1, COLOR_WHITE, COLOR_BLUE); // 헤더
init_pair(2, COLOR_YELLOW, COLOR_BLACK); // 눈사람
init_pair(3, COLOR_WHITE, COLOR_BLACK); // 눈송이
init_pair(4, COLOR_RED, COLOR_BLACK); // 목표물
init_pair(5, COLOR_CYAN, COLOR_BLACK); // 점수판
init_pair(6, COLOR_GREEN, COLOR_BLACK); // 단어 블록
}
resizeterm(gameHeight, gameWidth);
printf("\033[8;%d;%dt", gameHeight, gameWidth);
fflush(stdout);
clear();
refresh();
gameManager = new GameManager(currentLevel);
sentenceManager = new SentenceManager(currentLevel);
gameManager->startGame(sentenceManager);
}
~PlayScreen()
{
delete gameManager;
delete sentenceManager;
endwin();
}
void resizeTerminal(int width, int height)
{
resizeterm(height, width);
clear();
}
// 필수 함수 구현 (누락 방지)
void resizeScreen() override
{
resizeterm(gameHeight, gameWidth);
clear();
}
// ---------------------------------------------------------
// 메인 화면 업데이트 함수 (Public)
// ---------------------------------------------------------
void UpdateScreen() override
{
clear();
// 1. 데이터 업데이트
gameManager->updateTime();
sentenceManager->spawnItemBoxIfNeeded(gameAreaWidth, gameHeight - 3);
// 눈사람 완성 체크 및 애니메이션 처리
if (sentenceManager->getCorrectMatches() == 8 && !snowmanCompleted)
{
snowmanCompleted = true;
snowmanCompletedTime = time(nullptr);
showCompletedSnowman = true;
gameManager->notifySnowmanComplete();
}
// 2초 후 입력칸 초기화 및 눈사람 상태 변경
if (snowmanCompleted && showCompletedSnowman)
{
time_t currentTime = time(nullptr);
if (difftime(currentTime, snowmanCompletedTime) >= 2.0)
{
showCompletedSnowman = false;
snowmanCompleted = false;
// 입력칸 모두 비우기
sentenceManager->getInputHandler()->resetInputs();
gameManager->prepareNextRound(sentenceManager);
}
}
// 단어 블록 이동 (1초 간격)
if (gameManager->shouldUpdateWordBlocks())
{
sentenceManager->advanceWordBlocks(gameHeight - 3); // maxHeight 전달
if (sentenceManager->getTimePanalty())
{
gameManager->applyTimePenalty();
sentenceManager->setTimePanalty(false);
}
sentenceManager->advanceItemBoxes(gameHeight - 3);
}
// 단어 생성 처리 (8개 제한 및 완성 체크)
gameManager->handleWordGeneration(sentenceManager);
// 게임 종료 조건 확인
if (gameManager->checkGameEnd())
{
gameRunning = false;
}
// 전체 프레임 그리기
drawFrame();
// 게임 영역 배경 효과
drawBackgroundEffect();
// 아이템 효과 알림 (3초간 강조 표시)
if (gameManager->shouldDisplayItemEffect())
{
attron(COLOR_PAIR(4) | A_BOLD);
mvprintw(4, 2, "*** %s ***", gameManager->getLastItemEffectMessage().c_str());
attroff(COLOR_PAIR(4) | A_BOLD);
}
// 게임 영역 내용 (왼쪽) - 배경만
for (int row = 3; row < gameHeight - 2; row++)
{
for (int col = 1; col < gameAreaWidth; col++)
{
if (row == 5 || row == gameHeight - 5)
{
if (col % 8 == 0)
{
attron(COLOR_PAIR(3));
mvprintw(row, col, "*"); // 눈송이
attroff(COLOR_PAIR(3));
}
}
else if (col % 15 == 0 && row % 6 == 0)
{
attron(COLOR_PAIR(3));
mvprintw(row, col, "~"); // 눈 내리는 효과
attroff(COLOR_PAIR(3));
}
else if (row == gameHeight - 4 && col % 12 == 0)
{
attron(COLOR_PAIR(4));
mvprintw(row, col, "X"); // 목표물
attroff(COLOR_PAIR(4));
}
}
}
// 단어 블록 렌더링 (배경보다 먼저 그려서 덮어씌우기)
attron(COLOR_PAIR(6) | A_BOLD);
const auto &wordBlocks = sentenceManager->getWordBlocks();
for (const auto &block : wordBlocks)
{
// active 체크와 화면 범위 체크
if (block.active && block.getY() >= 3 && block.getY() < gameHeight - 2)
{
int blockX = block.getX();
int blockY = block.getY();
// 단어가 화면 범위 내에 있는지 확인
if (blockX >= 1 && blockX + (int)block.word.length() < gameAreaWidth - 1)
{
mvprintw(blockY, blockX, "%s", block.word.c_str());
}
}
}
attroff(COLOR_PAIR(6) | A_BOLD);
// 아이템 박스 렌더링
attron(COLOR_PAIR(4) | A_BOLD);
const auto &itemBoxes = sentenceManager->getItemBoxes();
for (const auto &box : itemBoxes)
{
if (box.getIsActive() && box.getY() >= 3 && box.getY() < gameHeight - 2)
{
int boxX = box.getX();
int boxY = box.getY();
if (boxX >= 1 && boxX + 2 < gameAreaWidth - 1)
{
mvprintw(boxY, boxX, "[?]");
}
}
}
attroff(COLOR_PAIR(4) | A_BOLD);
// 오른쪽 영역 (수정된 drawInfoPanel 호출)
drawInfoPanel();
refresh();
}
void shapeScreen() override
{
printf("Game screen shaped for level %d\n", currentLevel);
}
void runPlayScreen()
{
int key;
while (gameRunning)
{
UpdateScreen();
timeout(50);
key = ::getch();
if (key != ERR)
{
switch (key)
{
case 27: // ESC
gameRunning = false;
break;
case '\t': // TAB
case KEY_DOWN:
sentenceManager->getInputHandler()->nextInput();
break;
case KEY_UP:
sentenceManager->getInputHandler()->previousInput();
break;
default:
{
auto handler = sentenceManager->getInputHandler();
int beforeIndex = handler->getCurrentInputIndex();
if (handler->handleInput(key))
{
int usedIndex = beforeIndex;
std::string submitted = handler->getInputAt(usedIndex);
std::string lowered = submitted;
std::transform(lowered.begin(), lowered.end(), lowered.begin(), ::tolower);
if (lowered == "random")
{
ItemBox::ItemType type;
if (sentenceManager->tryUseActiveItemBox(type))
{
gameManager->applyItemEffect(type);
handler->clearInput(usedIndex);
}
}
sentenceManager->checkAnswers();
}
}
break;
}
}
}
gameManager->endGame();
clear();
attron(COLOR_PAIR(1) | A_BOLD);
mvprintw(gameHeight / 2 - 3, gameWidth / 2 - 15, "GAME OVER");
mvprintw(gameHeight / 2 - 1, gameWidth / 2 - 20, "Final Score: %d", gameManager->getTotalScore());
mvprintw(gameHeight / 2 + 3, gameWidth / 2 - 15, "Press any key to exit...");
attroff(COLOR_PAIR(1) | A_BOLD);
refresh();
timeout(-1);
::getch();
endwin();
}
};
class InitialScreen : public Screen
{
private:
int selectedLevel;
bool playButtonPressed;
public:
InitialScreen() : selectedLevel(1), playButtonPressed(false)
{
setlocale(LC_ALL, "");
initscr();
noecho();
cbreak();
keypad(stdscr, TRUE);
curs_set(0);
if (has_colors())
{
start_color();
init_pair(1, COLOR_CYAN, COLOR_BLACK);
init_pair(2, COLOR_YELLOW, COLOR_BLACK);
init_pair(3, COLOR_WHITE, COLOR_BLACK);
}
}
~InitialScreen() { endwin(); }
void UpdateScreen() override
{
clear();
attron(COLOR_PAIR(1) | A_BOLD);
mvprintw(2, 15, " _____ _ _ _____ _ _ __ __ _ _ ");
mvprintw(3, 15, " / ____| \\ | |/ _ \\ \\| | | | | \\/ | /\\ | \\ | |");
mvprintw(4, 15, "| (___ | \\| | | | | | | | | | |\\/| | / \\ | \\| |");
mvprintw(5, 15, " \\___ \\| . ` | | | | | |/\\| | | | | | / /\\ \\ | . ` |");
mvprintw(6, 15, " ____) | |\\ | |_| | \\ /\\ / | | | |/ ____ \\| |\\ |");
mvprintw(7, 15, "|_____/|_| \\_|\\___/ \\_\\/ \\/ |_| |_/_/ \\_\\_| \\_|");
attroff(COLOR_PAIR(1) | A_BOLD);
attron(COLOR_PAIR(1));
mvprintw(9, 20, "*** WELCOME TO SNOW MAN GAME ***");
attroff(COLOR_PAIR(1));
mvprintw(12, 30, "SELECT LEVEL:");
for (int i = 1; i <= 3; i++)
{
if (selectedLevel == i)
{
attron(COLOR_PAIR(2) | A_BOLD);
mvprintw(13 + i, 25, ">>> [%d] Level %d - %s <<<", i, i, (i == 1 ? "Easy" : i == 2 ? "Medium" : "Hard"));
attroff(COLOR_PAIR(2) | A_BOLD);
}
else
{
attron(COLOR_PAIR(3));
mvprintw(13 + i, 29, "[%d] Level %d - %s", i, i, (i == 1 ? "Easy" : i == 2 ? "Medium" : "Hard"));
attroff(COLOR_PAIR(3));
}
}
attron(COLOR_PAIR(3));
mvprintw(18, 32, "[P] PLAY GAME");
mvprintw(19, 34, "[Q] QUIT");
attroff(COLOR_PAIR(3));
refresh();
}
void resizeScreen() override {}
void shapeScreen() override {}
void runInitialScreen()
{
int key;
while (!playButtonPressed)
{
UpdateScreen();
key = ::getch();
switch (key)
{
case KEY_UP:
if (selectedLevel > 1)
selectedLevel--;
break;
case KEY_DOWN:
if (selectedLevel < 3)
selectedLevel++;
break;
case '1':
selectedLevel = 1;
break;
case '2':
selectedLevel = 2;
break;
case '3':
selectedLevel = 3;
break;
case 'P':
case 'p':
playButtonPressed = true;
{
endwin();
PlayScreen *pScreen = new PlayScreen(selectedLevel);
pScreen->runPlayScreen();
delete pScreen;
initscr();
noecho();
cbreak();
keypad(stdscr, TRUE);
curs_set(0);
if (has_colors())
{
start_color();
}
playButtonPressed = false;
}
break;
case 'Q':
case 'q':
endwin();
exit(0);
break;
}
}
}
};
#endif