Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Python - LibTCod sample
- # +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
- # Import
- import tcod as libtcod
- # +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
- screen_width = 50
- screen_height = 30
- # +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
- # Init console
- libtcod.console_init_root(screen_width, screen_height, "My Game")
- # +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
- # Peripherals
- key = libtcod.Key()
- mouse = libtcod.Mouse()
- # +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
- # Game Loop
- while not libtcod.console_is_window_closed():
- libtcod.console_set_default_foreground(0, libtcod.white)
- libtcod.sys_check_for_event(libtcod.EVENT_KEY_PRESS, key, mouse)
- # Here are our code
- # ...
- # Send image to the console
- libtcod.console_flush()
- # Keyboard operations
- if key.vk == libtcod.KEY_ESCAPE:
- return
- # ================
- # Functions
- # ================
- # Put char at x,y pos
- def cchar(x, y, c):
- t.console_put_char(0, x, y, ord(c))
- # Put text at x,y pos
- def cprint(x, y, txt):
- t.console_print(0, x, y, txt)
- # Clear all the console
- def cclear():
- t.console_clear(0)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement