Advertisement
HaxiDenti

Untitled

Mar 1st, 2021
2,019
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.04 KB | None | 0 0
  1. # Python - LibTCod sample
  2.  
  3. # +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
  4. # Import
  5. import tcod as libtcod
  6.  
  7. # +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
  8. screen_width = 50
  9. screen_height = 30
  10.  
  11. # +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
  12. # Init console
  13. libtcod.console_init_root(screen_width, screen_height, "My Game")
  14.  
  15. # +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
  16. # Peripherals
  17. key = libtcod.Key()
  18. mouse = libtcod.Mouse()
  19.  
  20. # +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
  21. # Game Loop
  22. while not libtcod.console_is_window_closed():
  23.     libtcod.console_set_default_foreground(0, libtcod.white)
  24.     libtcod.sys_check_for_event(libtcod.EVENT_KEY_PRESS, key, mouse)
  25.  
  26.     # Here are our code
  27.     # ...
  28.  
  29.     # Send image to the console
  30.     libtcod.console_flush()
  31.  
  32.     # Keyboard operations
  33.     if key.vk == libtcod.KEY_ESCAPE:
  34.         return
  35.  
  36.  
  37. # ================
  38. # Functions
  39. # ================
  40.  
  41. # Put char at x,y pos
  42. def cchar(x, y, c):
  43.     t.console_put_char(0, x, y, ord(c))
  44.  
  45. # Put text at x,y pos
  46. def cprint(x, y, txt):
  47.     t.console_print(0, x, y, txt)
  48.  
  49. # Clear all the console
  50. def cclear():
  51.     t.console_clear(0)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement