Add some more basic colors and some semantic colors for the Health Bar
This commit is contained in:
parent
11aee12320
commit
18a068cff6
2 changed files with 40 additions and 5 deletions
|
@ -86,7 +86,7 @@ class Engine:
|
||||||
self.update_field_of_view()
|
self.update_field_of_view()
|
||||||
|
|
||||||
# Interface elements
|
# Interface elements
|
||||||
self.hit_points_bar = Bar(position=Point(4, 45), width=20)
|
self.hit_points_bar = Bar(position=Point(4, 45), width=20, colors=list(color.HealthBar.bar_colors()))
|
||||||
|
|
||||||
self.message_log.add_message('Greetings adventurer!', fg=(127, 127, 255), stack=False)
|
self.message_log.add_message('Greetings adventurer!', fg=(127, 127, 255), stack=False)
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,45 @@
|
||||||
# Eryn Wells <eryn@erynwells.me>
|
# Eryn Wells <eryn@erynwells.me>
|
||||||
|
# pylint: disable=too-few-public-methods
|
||||||
|
|
||||||
'''
|
'''
|
||||||
A bunch of colors.
|
A bunch of colors.
|
||||||
'''
|
'''
|
||||||
|
|
||||||
BLACK = (0, 0, 0)
|
from typing import Iterator, Tuple
|
||||||
WHITE = (255, 255, 255)
|
|
||||||
GREY10 = (26, 26, 26)
|
Color = Tuple[int, int, int]
|
||||||
GREY50 = (128, 128, 128)
|
|
||||||
|
# Grayscale
|
||||||
|
BLACK = (0x00, 0x00, 0x00)
|
||||||
|
GREY12 = (0x20, 0x20, 0x20)
|
||||||
|
GREY25 = (0x40, 0x40, 0x40)
|
||||||
|
GREY50 = (0x80, 0x80, 0x80)
|
||||||
|
GREY75 = (0xC0, 0xC0, 0xC0)
|
||||||
|
WHITE = (0xFF, 0xFF, 0xFF)
|
||||||
|
|
||||||
|
# Primaries
|
||||||
|
BLUE = (0x00, 0x00, 0xFF)
|
||||||
|
CYAN = (0x00, 0xFF, 0xFF)
|
||||||
|
GREEN = (0x00, 0xFF, 0x00)
|
||||||
|
MAGENTA = (0xFF, 0x00, 0xFF)
|
||||||
|
RED = (0xFF, 0x00, 0x00)
|
||||||
|
YELLOW = (0xFF, 0xFF, 0x00)
|
||||||
|
ORANGE = (0xFF, 0x77, 0x00)
|
||||||
|
|
||||||
|
# Semantic
|
||||||
|
class HealthBar:
|
||||||
|
'''Semantic colors for the health bar'''
|
||||||
|
FULL = GREEN
|
||||||
|
GOOD = GREEN
|
||||||
|
OKAY = YELLOW
|
||||||
|
LOW = ORANGE
|
||||||
|
CRITICAL = RED
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def bar_colors() -> Iterator[Tuple[float, Color]]:
|
||||||
|
'''Return an iterator of colors that a Bar class can use'''
|
||||||
|
yield (0.1, HealthBar.CRITICAL)
|
||||||
|
yield (0.25, HealthBar.LOW)
|
||||||
|
yield (0.75, HealthBar.OKAY)
|
||||||
|
yield (0.9, HealthBar.GOOD)
|
||||||
|
yield (1.0, HealthBar.FULL)
|
Loading…
Add table
Add a link
Reference in a new issue