Created
July 13, 2019 11:33
-
-
Save FractalWire/3e40543a332d16cd147bd1cf0ff943b6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import tcod | |
import tcod.event | |
def main(): | |
width = 60 | |
height = 40 | |
font = "data/fonts/dejavu16x16_gs_tc.png" | |
flag = tcod.FONT_LAYOUT_TCOD | tcod.FONT_TYPE_GREYSCALE | |
tcod.console_set_custom_font(font, flag) | |
root_console = tcod.console_init_root(width, height, | |
"testing space printing", | |
False, | |
tcod.constants.RENDERER_OPENGL) | |
root_console.clear(bg=(20,)*3, fg=tcod.white) | |
con1 = tcod.console.Console(20, 20) | |
con1.clear(bg=(0,)*3) | |
con2 = tcod.console.Console(20, 20) | |
con2.clear(ch=ord('.'), bg=(0,)*3) | |
con3 = tcod.console.Console(20, 20) | |
con3.print_box(5, 5, 10, 10, "This is\na test\nfor print_box", | |
alignment=tcod.constants.CENTER) | |
con4 = tcod.console.Console(20, 20) | |
con4.clear(ch=ord('.'), bg=(0,)*3) | |
con4.print_box(5, 5, 10, 10, "This is\na test\nfor print_box", | |
alignment=tcod.constants.CENTER) | |
con5 = tcod.console.Console(20, 20) | |
con5.clear(bg=(60,)*3) | |
con6 = tcod.console.Console(20, 20) | |
con6.clear(ch=ord('.'), bg=(60,)*3) | |
con6.print_box(5, 5, 10, 10, "This is\na test\nfor print_box", | |
alignment=tcod.constants.CENTER) | |
while not tcod.console_is_window_closed(): | |
tcod.console_flush() | |
con1.blit(root_console, 0, 0) | |
con2.blit(root_console, 20, 0) | |
con3.blit(root_console, 0, 20) | |
con4.blit(root_console, 20, 20) | |
con5.blit(root_console, 40, 0) | |
con6.blit(root_console, 40, 20) | |
handle_events() | |
def handle_events(): | |
global val | |
for event in tcod.event.wait(): | |
if event.type == "KEYDOWN": | |
if event.sym == tcod.event.K_ESCAPE: | |
raise SystemExit() | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment