feat(chargen): add color params

This commit is contained in:
shokre 2021-09-16 17:25:40 +02:00
parent 28632a1d32
commit 91828eaa3e

View file

@ -6,17 +6,17 @@ def chargen_init(char_data):
chars = char_data chars = char_data
def chargen_draw_char(surf, px, py, ch): def chargen_draw_char(surf, px, py, ch, color=(0, 255, 0), bg=(0, 0, 0)):
char_loc = (ord(ch) - 32) * 8 char_loc = (ord(ch) - 32) * 8
for y in range(8): for y in range(8):
c = chars[char_loc + y] c = chars[char_loc + y]
for x in range(8): for x in range(8):
if (c >> x) & 1: if (c >> x) & 1:
surf.set_at((px + x, py + y), (0, 255, 0)) surf.set_at((px + x, py + y), color)
else: else:
surf.set_at((px + x, py + y), (0, 0, 0)) surf.set_at((px + x, py + y), bg)
def chargen_draw_str(surf, px, py, str): def chargen_draw_str(surf, px, py, str, color=(0, 255, 0), bg=(0, 0, 0)):
for x in range(len(str)): for x in range(len(str)):
chargen_draw_char(surf, px + x * 8, py, str[x]) chargen_draw_char(surf, px + x * 8, py, str[x], color=color, bg=bg)