pretty now :)
This commit is contained in:
parent
b362b3fe1d
commit
bb6ad2ec56
BIN
__pycache__/colours.cpython-313.pyc
Normal file
BIN
__pycache__/colours.cpython-313.pyc
Normal file
Binary file not shown.
46
colours.py
Normal file
46
colours.py
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
# SGR color constants
|
||||
# rene-d 2018
|
||||
|
||||
class Colours:
|
||||
""" ANSI color codes """
|
||||
BLACK = "\033[0;30m"
|
||||
RED = "\033[0;31m"
|
||||
GREEN = "\033[0;32m"
|
||||
BROWN = "\033[0;33m"
|
||||
BLUE = "\033[0;34m"
|
||||
PURPLE = "\033[0;35m"
|
||||
CYAN = "\033[0;36m"
|
||||
LIGHT_GRAY = "\033[0;37m"
|
||||
DARK_GRAY = "\033[1;30m"
|
||||
LIGHT_RED = "\033[1;31m"
|
||||
LIGHT_GREEN = "\033[1;32m"
|
||||
YELLOW = "\033[1;33m"
|
||||
LIGHT_BLUE = "\033[1;34m"
|
||||
LIGHT_PURPLE = "\033[1;35m"
|
||||
LIGHT_CYAN = "\033[1;36m"
|
||||
LIGHT_WHITE = "\033[1;37m"
|
||||
BOLD = "\033[1m"
|
||||
FAINT = "\033[2m"
|
||||
ITALIC = "\033[3m"
|
||||
UNDERLINE = "\033[4m"
|
||||
BLINK = "\033[5m"
|
||||
NEGATIVE = "\033[7m"
|
||||
CROSSED = "\033[9m"
|
||||
END = "\033[0m"
|
||||
# cancel SGR codes if we don't write to a terminal
|
||||
if not __import__("sys").stdout.isatty():
|
||||
for _ in dir():
|
||||
if isinstance(_, str) and _[0] != "_":
|
||||
locals()[_] = ""
|
||||
else:
|
||||
# set Windows console in VT mode
|
||||
if __import__("platform").system() == "Windows":
|
||||
kernel32 = __import__("ctypes").windll.kernel32
|
||||
kernel32.SetConsoleMode(kernel32.GetStdHandle(-11), 7)
|
||||
del kernel32
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
for i in dir(Colours):
|
||||
if i[0:1] != "_" and i != "END":
|
||||
print("{:>16} {}".format(i, getattr(Colours, i) + i + Colours.END))
|
||||
5
main.py
5
main.py
|
|
@ -1,5 +1,6 @@
|
|||
import os
|
||||
import sys
|
||||
from colours import Colours
|
||||
|
||||
def clear():
|
||||
if sys.platform.startswith('win'):
|
||||
|
|
@ -75,7 +76,7 @@ board = [
|
|||
]
|
||||
|
||||
playing = True
|
||||
turn = 'R'
|
||||
turn = f'{Colours.RED}{Colours.BOLD}R{Colours.END}'
|
||||
|
||||
while playing:
|
||||
clear()
|
||||
|
|
@ -100,4 +101,4 @@ while playing:
|
|||
|
||||
board[chosenColumn][tile] = turn
|
||||
|
||||
turn = 'Y' if turn == 'R' else 'R'
|
||||
turn = f'{Colours.YELLOW}{Colours.BOLD}Y{Colours.END}' if turn == f'{Colours.RED}{Colours.BOLD}R{Colours.END}' else f'{Colours.RED}{Colours.BOLD}R{Colours.END}'
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user