Изменил(а) на 'a3/game.c'

This commit is contained in:
Vladyslav Korzun 2023-04-26 19:29:34 +00:00
parent a9ac59407f
commit 63d0679495

View File

@ -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));
}
}
}