/firstrl.py Secret
Created
June 17, 2016 12:51
Star
You must be signed in to star a gist
A roguelike in Python, using libtcod.
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
# The name libtcodpy is very funky (sorry Jice!) | |
import libtcodpy as libtcod | |
SCREEN_WIDTH = 80 | |
SCREEN_HEIGHT = 50 | |
LIMIT_FPS = 20 | |
def handle_keys(): | |
key = libtcod.console_wait_for_keypress(True) | |
if key.vk == libtcod.KEY_ESCAPE: | |
# Exit game | |
return True | |
libtcod.console_set_custom_font( | |
'arial10x10.png', libtcod.FONT_TYPE_GREYSCALE | libtcod.FONT_LAYOUT_TCOD | |
) | |
libtcod.console_init_root( | |
SCREEN_WIDTH, SCREEN_HEIGHT, 'firstrl', False | |
) | |
while not libtcod.console_is_window_closed(): | |
libtcod.console_set_default_foreground(0, libtcod.white) | |
libtcod.console_put_char(0, 0, 1, 'H', libtcod.BKGND_NONE) | |
libtcod.console_put_char(0, 1, 1, 'e', libtcod.BKGND_NONE) | |
libtcod.console_put_char(0, 2, 1, 'l', libtcod.BKGND_NONE) | |
libtcod.console_put_char(0, 3, 1, 'l', libtcod.BKGND_NONE) | |
libtcod.console_put_char(0, 4, 1, 'o', libtcod.BKGND_NONE) | |
libtcod.console_put_char(0, 5, 1, ',', libtcod.BKGND_NONE) | |
libtcod.console_put_char(0, 7, 1, 'W', libtcod.BKGND_NONE) | |
libtcod.console_put_char(0, 8, 1, 'o', libtcod.BKGND_NONE) | |
libtcod.console_put_char(0, 9, 1, 'r', libtcod.BKGND_NONE) | |
libtcod.console_put_char(0, 10, 1, 'l', libtcod.BKGND_NONE) | |
libtcod.console_put_char(0, 11, 1, 'd', libtcod.BKGND_NONE) | |
libtcod.console_put_char(0, 12, 1, '!', libtcod.BKGND_NONE) | |
libtcod.console_flush() | |
# Handle keys and break out of the loop | |
finished = handle_keys() | |
if finished: | |
break |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment