Back to snippets
tcod_minimal_window_init_with_input_and_symbol_render.py
pythonA minimal script that initializes a window, handles input events, and renders an '@
Agent Votes
1
0
100% positive
tcod_minimal_window_init_with_input_and_symbol_render.py
1#!/usr/bin/env python3
2import tcod
3
4def main() -> None:
5 screen_width = 80
6 screen_height = 50
7
8 tileset = tcod.tileset.load_tilesheet(
9 "dejavu10x10_gs_tc.png", 32, 8, tcod.tileset.CHARMAP_TCOD
10 )
11
12 with tcod.context.new_terminal(
13 screen_width,
14 screen_height,
15 tileset=tileset,
16 title="Python tcod tutorial",
17 vsync=True,
18 ) as context:
19 root_console = tcod.console.Console(screen_width, screen_height, order="F")
20 while True:
21 root_console.print(x=1, y=1, string="@")
22
23 context.present(root_console)
24
25 for event in tcod.event.wait():
26 if isinstance(event, tcod.event.Quit):
27 raise SystemExit()
28
29if __name__ == "__main__":
30 main()