Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Colors to Game #34

Open
evanugarte opened this issue May 20, 2020 · 1 comment · May be fixed by #46
Open

Add Colors to Game #34

evanugarte opened this issue May 20, 2020 · 1 comment · May be fixed by #46
Assignees
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@evanugarte
Copy link
Collaborator

This article discusses using the macros build into the ncurses library. We could do this approach but I also wanted to test out creating our own enums like below:

class colors:
    """
    This is a class that helps with printing out colors to the terminal.
    """
    PINK = '\033[95m'
    PURPLE = '\033[94m'
    GREEN = '\033[92m'
    YELLOW = '\033[93m'
    RED = '\033[91m'
    ENDC = '\033[0m'
@evanugarte evanugarte added enhancement New feature or request help wanted Extra attention is needed labels May 20, 2020
@drofp
Copy link
Owner

drofp commented May 21, 2020

Since ncurses is a C library and color pairs can only be bound to an integer, and not enums, it might be a good idea to have a wrapper class or function around the native ncurses color functions so we can use enums easily.

Also, there's a lot of ncurses patterns like this one below that should really just be a single function call:

attron(COLOR_PAIR(PLAYER_PAIR));
mvaddch(y, x, PLAYER);
attroff(COLOR_PAIR(PLAYER_PAIR));

so a wrapper would help handle this as well.

@evanugarte evanugarte self-assigned this Oct 5, 2020
evanugarte added a commit that referenced this issue Oct 5, 2020
@evanugarte evanugarte linked a pull request Oct 5, 2020 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants