Added enColor and disColor to simplify colors
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
# Changelog
|
||||
|
||||
## V1.1 (unreleased):
|
||||
|
||||
* Added color mode
|
||||
|
||||
## V1.0 (30.08.2017):
|
||||
* Initial release
|
||||
|
18
hangman.c
18
hangman.c
@@ -116,11 +116,11 @@ void quitProgram(void) {
|
||||
}
|
||||
|
||||
void showStartScreen(game_state *gs) {
|
||||
attron(COLOR_PAIR(1));
|
||||
enColor(1);
|
||||
mvprintw(gs->centery - 1, gs->centerx - 15, "Welcome to hangman in ncurses.");
|
||||
mvprintw(gs->centery, gs->centerx - 5, "Have fun!");
|
||||
mvprintw(gs->centery + 1, gs->centerx - 17, "https://gitlab.com/STRUCTiX/hangman");
|
||||
attroff(COLOR_PAIR(1));
|
||||
disColor(1);
|
||||
refresh();
|
||||
getch();
|
||||
clear();
|
||||
@@ -450,7 +450,7 @@ void printHitFeed(game_state *gs, hitfeed *hf) {
|
||||
int newMaxy = gs->maxy - HITFEEDSLOTS;
|
||||
int newMaxx = gs->maxx - (gs->centerx / 2);
|
||||
int i, z;
|
||||
attron(COLOR_PAIR(3)); //Enable red color
|
||||
enColor(3); //Enable red color
|
||||
for (i = -1; i < HITFEEDSLOTS; i++) {
|
||||
for (z = 0; z <= gs->maxx - newMaxx; z++) {
|
||||
mvprintw(newMaxy + i, newMaxx + z, " ");
|
||||
@@ -466,7 +466,7 @@ void printHitFeed(game_state *gs, hitfeed *hf) {
|
||||
sprintf(message, "Best: %s (%i hits)", hf->beststreak, hf->besthit);
|
||||
mvprintw(newMaxy - 1, newMaxx, message);
|
||||
}
|
||||
attroff(COLOR_PAIR(3)); //Disable red color
|
||||
disColor(3); //Disable red color
|
||||
}
|
||||
}
|
||||
|
||||
@@ -526,3 +526,13 @@ void animateLineClear(game_state *gs, int line, int offsetMultiplier) {
|
||||
mvprintw(line, k, " ");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void enColor(int color) {
|
||||
attron(COLOR_PAIR(color));
|
||||
}
|
||||
|
||||
|
||||
void disColor(int color) {
|
||||
attroff(COLOR_PAIR(color));
|
||||
}
|
||||
|
@@ -69,3 +69,5 @@ void trollHandleImpressive(hitfeed *hf, game_state *gs, int hits);
|
||||
void drawFigure(game_state *gs, int drawNext);
|
||||
void animateLineClear(game_state *gs, int line, int offsetMultiplier);
|
||||
void printHitFeed(game_state *gs, hitfeed *hf);
|
||||
void enColor(int color);
|
||||
void disColor(int color);
|
||||
|
Reference in New Issue
Block a user