From 63d067949578cbc8052eea258b8238cb4f974f15 Mon Sep 17 00:00:00 2001 From: Vladyslav Korzun Date: Wed, 26 Apr 2023 19:29:34 +0000 Subject: [PATCH] =?UTF-8?q?=D0=98=D0=B7=D0=BC=D0=B5=D0=BD=D0=B8=D0=BB(?= =?UTF-8?q?=D0=B0)=20=D0=BD=D0=B0=20'a3/game.c'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- a3/game.c | 36 ++++++++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/a3/game.c b/a3/game.c index b8a7a54..eb60edf 100644 --- a/a3/game.c +++ b/a3/game.c @@ -38,6 +38,27 @@ int game_event(struct event* event,void* game){ mouse_count++; if(mouse_count == 5){ clear_screen(); + start_color(); + init_pair(1, COLOR_RED, COLOR_BLACK); + init_pair(2, COLOR_GREEN, COLOR_BLACK); + init_pair(3, COLOR_YELLOW, COLOR_BLACK); + init_pair(4, COLOR_BLUE, COLOR_BLACK); + init_pair(5, COLOR_MAGENTA, COLOR_BLACK); + init_pair(6, COLOR_CYAN, COLOR_BLACK); + init_pair(7, COLOR_WHITE, COLOR_BLACK); + + char* text = "You Win!(,,,)=(^.^)=(,,,)"; + int len = strlen(text); + for (int i = 0; i < len; i++) { + attron(COLOR_PAIR(i % 7 + 1)); + mvprintw(15, 30 + i, "%c", text[i]); + attroff(COLOR_PAIR(i % 7 + 1)); + refresh(); + napms(100); + } + + napms(1000); + endwin(); return 0; } } @@ -104,23 +125,22 @@ int game_event(struct event* event,void* game){ } } count = 0; - // Draw world state + clear_screen(); initscr(); start_color(); -init_pair(1, COLOR_BLUE, COLOR_BLUE); // цветовая пара для стен - белый на голубом -init_pair(2, COLOR_BLACK, COLOR_BLACK); // цветовая пара для мышей - черный на белом - +init_pair(1, COLOR_BLUE, COLOR_BLUE); +init_pair(2, COLOR_BLACK, COLOR_BLACK); for (int y = 10; y < 20; y++) { for (int x = 10; x < 40; x++) { if (x == 10 || y == 10 || x == 39 || y == 19) { - attron(COLOR_PAIR(1)); // включаем цветовую пару для стен + attron(COLOR_PAIR(1)); mvaddch(y, x, '#'); - attroff(COLOR_PAIR(1)); // выключаем цветовую пару для стен + attroff(COLOR_PAIR(1)); } else { - attron(COLOR_PAIR(2)); // включаем цветовую пару для мышей + attron(COLOR_PAIR(2)); mvaddch(y, x, ' '); - attroff(COLOR_PAIR(2)); // выключаем цветовую пару для мышей + attroff(COLOR_PAIR(2)); } } }