Пример #1
0
 def render_intro(self, intro_text):
     libtcod.console_print(self.con2, SCREEN_WIDTH / 3, (SCREEN_HEIGHT /3) , intro_text)
     # do a cross-fading from off1 to off2
     for i in range(1, 110):
         libtcod.console_blit(self.con, 0, 0, VIEWPORT_WIDTH, VIEWPORT_HEIGHT, 0, 0, 0) # renders the first screen (opaque)
         libtcod.console_blit(self.con2, 0, 0, VIEWPORT_WIDTH, VIEWPORT_HEIGHT, 0, 0, 0, i / 128.0,
                              i / 128.0) # renders the second screen (transparent)
         libtcod.console_flush()
     libtcod.sys_check_for_event(libtcod.EVENT_KEY_PRESS, self.key, self.mouse)
     for i in range(1, 128):
         libtcod.console_blit(self.con2, 0, 0, VIEWPORT_WIDTH, VIEWPORT_HEIGHT, 0, 0, 0) # renders the first screen (opaque)
         libtcod.console_blit(self.con, 0, 0, VIEWPORT_WIDTH, VIEWPORT_HEIGHT, 0, 0, 0, i / 128.0,
                              i / 128.0) # renders the second screen (transparent)
Пример #2
0
def readkey():
    global  key
    while True:
        libtcod.sys_check_for_event(libtcod.EVENT_KEY_PRESS, key, mouse)
        #No need to react on service keys
        if key.vk == libtcod.KEY_ENTER and key.vk == libtcod.KEY_ALT:
            #Alt+Enter: toggle fullscreen
            libtcod.console_set_fullscreen(not libtcod.console_is_fullscreen())
            continue
        if key.vk in [libtcod.KEY_SHIFT, libtcod.KEY_CONTROL, libtcod.KEY_ALT, libtcod.KEY_CAPSLOCK]:
            continue
        if key.c != 0 and chr(key.c) not in '\x1b\n\r\t':
            s = chr(key.c)
            if key.shift:
                s = s.upper()
            return s
        elif key.vk:
            return key.vk
Пример #3
0
 def render_dialog(self, title):
     libtcod.console_set_keyboard_repeat(1000, 500)
     libtcod.console_print_frame(self.con, 10, 10, 30, 3, True, libtcod.BKGND_NONE, title)
     line = ''
     while True:
         libtcod.console_print(self.con, 11, 11, ' '.rjust(len(line) + 2, ' '))
         libtcod.console_print(self.con, 11, 11, line + '_')
         libtcod.console_blit(self.con, 10, 10, 30, 3, 0, 10, 10)
         libtcod.console_flush()
         libtcod.sys_check_for_event(libtcod.EVENT_KEY_PRESS, self.key, self.mouse)
         key = self.key
         if key.c == 27:
             game_input.default_rate()
             return None
         if key.c == 13:
             game_input.default_rate()
             return line
         if key.c == 8:
             line = line[0:len(line) - 1]
         elif key.c != 0:
             line += chr(key.c)
Пример #4
0
def readkey():
    global key
    while True:
        libtcod.sys_check_for_event(libtcod.EVENT_KEY_PRESS, key, mouse)
        #No need to react on service keys
        if key.vk == libtcod.KEY_ENTER and key.vk == libtcod.KEY_ALT:
            #Alt+Enter: toggle fullscreen
            libtcod.console_set_fullscreen(not libtcod.console_is_fullscreen())
            continue
        if key.vk in [
                libtcod.KEY_SHIFT, libtcod.KEY_CONTROL, libtcod.KEY_ALT,
                libtcod.KEY_CAPSLOCK
        ]:
            continue
        if key.c != 0 and chr(key.c) not in '\x1b\n\r\t':
            s = chr(key.c)
            if key.shift:
                s = s.upper()
            return s
        elif key.vk:
            return key.vk
Пример #5
0
 def render_yn_dialog(self, title, warn=False):
     if warn:
         libtcod.console_set_default_foreground(self.con, libtcod.red)
     else:
         libtcod.console_set_default_foreground(self.con, libtcod.white)
     libtcod.console_set_keyboard_repeat(1000, 500)
     libtcod.console_print_frame(self.con, 10, 10, 30, 3, True, libtcod.BKGND_NONE, title)
     line = ''
     #todo - adjust the size of window to match line's size
     while True:
         libtcod.console_print_ex(self.con, 11, 11, libtcod.BKGND_NONE, libtcod.LEFT, ' '.rjust(len(line) + 2, ' '))
         libtcod.console_print_ex(self.con, 11, 11, libtcod.BKGND_NONE, libtcod.LEFT, line + '_')
         libtcod.console_blit(self.con, 10, 10, 30, 3, 0, 10, 10)
         libtcod.console_flush()
         libtcod.sys_check_for_event(libtcod.KEY_PRESSED, self.key, self.mouse)
         key = self.key
         if chr(key.c) == 'y' or chr(key.c) == 'Y' or key.c == 13:
             game_input.default_rate()
             return True
         if chr(key.c) == 'n' or chr(key.c) == 'N' or key.c == 27:
             game_input.default_rate()
             return False