feat(chargen): add color params
This commit is contained in:
parent
28632a1d32
commit
91828eaa3e
1 changed files with 5 additions and 5 deletions
|
@ -6,17 +6,17 @@ def chargen_init(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
|
||||
for y in range(8):
|
||||
c = chars[char_loc + y]
|
||||
for x in range(8):
|
||||
if (c >> x) & 1:
|
||||
surf.set_at((px + x, py + y), (0, 255, 0))
|
||||
surf.set_at((px + x, py + y), color)
|
||||
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)):
|
||||
chargen_draw_char(surf, px + x * 8, py, str[x])
|
||||
chargen_draw_char(surf, px + x * 8, py, str[x], color=color, bg=bg)
|
||||
|
|
Loading…
Reference in a new issue