コード例 #1
0
def init_screen():
    libtcod.console_set_custom_font('dejavu16x16_gs_tc.png',
                                    libtcod.FONT_TYPE_GRAYSCALE
                                    | libtcod.FONT_LAYOUT_TCOD)
    libtcod.console_init_root(WIDTH*3, WIDTH*3,
                              'The Smartest Dwarf in the Fortress', False)
    libtcod.console_set_default_foreground(0, libtcod.white)
コード例 #2
0
ファイル: gui.py プロジェクト: splaroche/Roguelike
    def __init__(self, mouse=None, key=None):
        # initialize the console
        # set the font, and consoles
        libtcod.console_set_custom_font('arial10x10.png', libtcod.FONT_TYPE_GREYSCALE | libtcod.FONT_LAYOUT_TCOD)
        libtcod.console_init_root(self.SCREEN_WIDTH, self.SCREEN_HEIGHT, 'python/libtcod tutorial', False)
        self.con = libtcod.console_new(self.MAP_WIDTH, self.MAP_HEIGHT)
        self.panel = libtcod.console_new(self.SCREEN_WIDTH, self.PANEL_HEIGHT)
        libtcod.sys_set_fps(self.LIMIT_FPS)

        # create the tile colors
        self.color_dark_wall = libtcod.Color(0, 0, 100)
        self.color_dark_ground = libtcod.Color(50, 50, 100)
        self.color_light_wall = libtcod.Color(130, 110, 50)
        self.color_light_ground = libtcod.Color(200, 180, 50)

        # set the fov initially to None.  This will be generated properly when the map is rendered
        self.fov_map = None
        self.fov_recompute = False

        # set the mous and keyboard capture vars
        self.mouse = mouse
        self.key = key

        # set the message console
        self.game_msgs = []
コード例 #3
0
def main():
    global key, mouse, map_, con

    R.SCREEN_WIDTH = 100
    R.SCREEN_HEIGHT = 80
    libtcod.console_set_custom_font("data\ont_big.png",
                                    libtcod.FONT_LAYOUT_ASCII_INROW)
    libtcod.console_init_root(R.SCREEN_WIDTH, R.SCREEN_HEIGHT, "Trader-RL",
                              False)
    libtcod.sys_set_fps(R.LIMIT_FPS)
    con = libtcod.console_new(R.SCREEN_WIDTH, R.SCREEN_HEIGHT)

    map_ = Map(R.MAP_WIDTH, R.MAP_HEIGHT)
    map_.wind_gen.run_simulation(500)

    mouse = libtcod.Mouse()
    key = libtcod.Key()

    while not libtcod.console_is_window_closed():
        libtcod.sys_check_for_event(
            libtcod.EVENT_KEY_PRESS | libtcod.EVENT_MOUSE, key, mouse)
        render()

        player_action = handle_keys()
        if player_action == "exit":
            break

        handle_mouse()
コード例 #4
0
ファイル: settings.py プロジェクト: Akhier/Py-TutMut
def init():
    libtcod.console_set_custom_font('terminal12x12_gs_ro.png',
                                    libtcod.FONT_TYPE_GREYSCALE |
                                    libtcod.FONT_LAYOUT_ASCII_INROW)
    libtcod.console_init_root(SCREEN_WIDTH, SCREEN_HEIGHT,
                              'basicroguelike', False)
    libtcod.sys_set_fps(LIMIT_FPS)
コード例 #5
0
ファイル: window.py プロジェクト: Alberdi/rogueforce
  def __init__(self, battleground, side, host = None, port = None, window_id = 0):
    if host is not None:
      self.network = Network(host, port)
    else:
      self.network = None
    self.bg = battleground
    self.side = side
    self.window_id = window_id

    libtcod.console_set_custom_font('arial10x10.png', libtcod.FONT_TYPE_GREYSCALE | libtcod.FONT_LAYOUT_TCOD)
    libtcod.console_init_root(SCREEN_WIDTH, SCREEN_HEIGHT, 'Rogue Force')

    self.messages = [{}, {}]

    self.con_root = libtcod.console_new(SCREEN_WIDTH, SCREEN_HEIGHT)
    self.con_bg = libtcod.console_new(BG_WIDTH, BG_HEIGHT)
    self.con_info = libtcod.console_new(INFO_WIDTH, INFO_HEIGHT)
    self.con_msgs = libtcod.console_new(MSG_WIDTH, MSG_HEIGHT)
    self.con_panels = [libtcod.console_new(PANEL_WIDTH, PANEL_HEIGHT), libtcod.console_new(PANEL_WIDTH, PANEL_HEIGHT)]

    self.game_msgs = []
    self.game_over = False
    self.area_hover_color = libtcod.green
    self.area_hover_color_invalid = libtcod.red
    self.default_hover_color = libtcod.blue
    self.default_hover_function = SingleTarget(self.bg).get_all_tiles
    self.hover_function = None
コード例 #6
0
ファイル: crogue.py プロジェクト: CalvinRodo/Crogue
  def __init__(self, font):
    self.di = DI()
    self.register_services()

    self.screen_height = 60
    self.screen_width = 100
    self.gamefont = sys.path[0] + '/data/fonts/' + font
    self.map = Map(80,45)
    self.fov_recompute = True

    self.game_state = "playing"
    self.player_action = None

    #create the root console
    libtcod.console_set_custom_font(self.gamefont.encode('utf-8'), libtcod.FONT_TYPE_GREYSCALE | libtcod.FONT_LAYOUT_ASCII_INROW)
    libtcod.console_init_root(self.screen_width, self.screen_height, 'crogue'.encode('utf-8'), False)

    #Create a console to draw to the screen
    self.con = libtcod.console_new(self.screen_width, self.screen_height)
    self.player = Player(self.map.starting_pos[0], self.map.starting_pos[1])
    self.objects = UserList()
    self.objects.append(self.player)

    self.Messages =  self.di.Request("Console")
    self.Messages.add_message("Game has been started.")

    self.load_monsters()
    self.add_monsters()
    self.add_items()
コード例 #7
0
ファイル: window.py プロジェクト: Alberdi/rogueforce
    def __init__(self, battleground, side, host=None, port=None, window_id=0):
        if host is not None:
            self.network = Network(host, port)
        else:
            self.network = None
        self.bg = battleground
        self.side = side
        self.window_id = window_id

        libtcod.console_set_custom_font(
            'arial10x10.png',
            libtcod.FONT_TYPE_GREYSCALE | libtcod.FONT_LAYOUT_TCOD)
        libtcod.console_init_root(SCREEN_WIDTH, SCREEN_HEIGHT, 'Rogue Force')

        self.messages = [{}, {}]

        self.con_root = libtcod.console.Console(SCREEN_WIDTH, SCREEN_HEIGHT)
        self.con_bg = libtcod.console.Console(BG_WIDTH, BG_HEIGHT)
        self.con_info = libtcod.console.Console(INFO_WIDTH, INFO_HEIGHT)
        self.con_msgs = libtcod.console.Console(MSG_WIDTH, MSG_HEIGHT)
        self.con_panels = [
            libtcod.console.Console(PANEL_WIDTH, PANEL_HEIGHT),
            libtcod.console.Console(PANEL_WIDTH, PANEL_HEIGHT)
        ]

        self.game_msgs = []
        self.game_over = False
        self.area_hover_color = libtcod.green
        self.area_hover_color_invalid = libtcod.red
        self.default_hover_color = libtcod.blue
        self.default_hover_function = SingleTarget(self.bg).get_all_tiles
        self.hover_function = None
コード例 #8
0
ファイル: __main__.py プロジェクト: magikmw/ldg
    def __init__(self):
        
        logg.info('Main loop initialization.')

        logg.debug('Font size set to 8')
        libtcod.console_set_custom_font('main/terminal8x8_gs_ro.png',
            libtcod.FONT_LAYOUT_ASCII_INROW | libtcod.FONT_TYPE_GRAYSCALE)

        logg.debug('Main console initialization.')
        libtcod.console_init_root(SCREEN_WIDTH, SCREEN_HEIGHT,
            WINDOW_TITLE + ' v.' + VERSION, False,
                renderer = libtcod.RENDERER_SDL)
        logg.debug('Setting the FPS limit.')
        libtcod.sys_set_fps(LIMIT_FPS)
        logg.debug('Drawing console initialization.')
        self.con = libtcod.console_new(SCREEN_WIDTH, SCREEN_HEIGHT)
        #bottom panel console
        logg.debug('Panels console initialization.')
        self.top_panel = libtcod.console_new(SCREEN_WIDTH, PANEL_HEIGHT)
        self.bottom_panel = libtcod.console_new(SCREEN_WIDTH, PANEL_HEIGHT)

        logg.debug('Gamestate variables initialization')
        self.entities=[]
        self.player = None
        self.gamestate = ""
        self.player_action = None
        self.map = None
        self.random = libtcod.random_new()
        self.score = 0
        self.gamemode = ''
コード例 #9
0
ファイル: game.py プロジェクト: pom2ter/immortal
	def __init__(self):
		global debug, font_width, font_height, con, panel, ps, fov_noise, savefiles, baseitems, prefix, suffix, tiles, monsters
		IO.load_settings()
		debug = dbg.Debug()
		debug.enable = True
		for key, value in fonts.items():
			if setting_font == key:
				libtcod.console_set_custom_font(value['file'], libtcod.FONT_TYPE_GREYSCALE | libtcod.FONT_LAYOUT_ASCII_INROW)
				font_width = value['width']
				font_height = value['height']
		self.init_root_console()
		#libtcod.console_init_root(SCREEN_WIDTH, SCREEN_HEIGHT, 'Immortal ' + VERSION, False)

		con = libtcod.console_new(MAP_WIDTH, MAP_HEIGHT)
		panel = libtcod.console_new(MESSAGE_WIDTH, MESSAGE_HEIGHT)
		ps = libtcod.console_new(PLAYER_STATS_WIDTH, PLAYER_STATS_HEIGHT)
		fov_noise = libtcod.noise_new(1, 1.0, 1.0)
		savefiles = [f for f in os.listdir('saves') if os.path.isfile(os.path.join('saves', f))]
		IO.load_high_scores()
		baseitems = BaseItemList()
		baseitems.init_parser()
		prefix = PrefixList()
		prefix.init_parser()
		suffix = SuffixList()
		suffix.init_parser()
		tiles = mapgen.TileList()
		tiles.init_parser()
		monsters = MonsterList()
		monsters.init_parser()
		self.main_menu()
コード例 #10
0
def main():
    constants = get_constants()

    libtcod.console_set_custom_font('arial10x10.png', libtcod.FONT_TYPE_GREYSCALE | libtcod.FONT_LAYOUT_TCOD)
    libtcod.console_init_root(constants['screen_width'], constants['screen_height'], constants['window_title'], False)

    main_screen(constants)
コード例 #11
0
ファイル: display.py プロジェクト: witheld9/r3-tdw
def boot():
	global SCREEN

	framework.events.register_event('draw', blit)

	tcod.console_set_custom_font(os.path.join('data', 'tiles', 'dejavu_wide12x12_gs_tc.png'),#,'consolas10x10_gs_tc.png')
	                             flags=tcod.FONT_LAYOUT_TCOD|tcod.FONT_TYPE_GREYSCALE)
	tcod.console_init_root(constants.WINDOW_WIDTH,
	                       constants.WINDOW_HEIGHT,
	                       constants.WINDOW_TITLE,
	                       fullscreen='--fullscreen' in sys.argv,
	                       renderer=tcod.RENDERER_GLSL)
	tcod.console_set_keyboard_repeat(200, 0)
	tcod.sys_set_fps(constants.FPS)	
	tcod.mouse_show_cursor(constants.SHOW_MOUSE)

	SCREEN['c'] = numpy.zeros((constants.WINDOW_HEIGHT, constants.WINDOW_WIDTH), dtype=numpy.int32)
	SCREEN['d'] = '0'*(constants.WINDOW_HEIGHT*constants.WINDOW_WIDTH)
	SCREEN['r'] = []

	SCREEN['f'] = []
	SCREEN['f'].append(numpy.zeros((constants.WINDOW_HEIGHT, constants.WINDOW_WIDTH), dtype=numpy.int16))
	SCREEN['f'].append(numpy.zeros((constants.WINDOW_HEIGHT, constants.WINDOW_WIDTH), dtype=numpy.int16))
	SCREEN['f'].append(numpy.zeros((constants.WINDOW_HEIGHT, constants.WINDOW_WIDTH), dtype=numpy.int16))

	SCREEN['b'] = []
	SCREEN['b'].append(numpy.zeros((constants.WINDOW_HEIGHT, constants.WINDOW_WIDTH), dtype=numpy.int16))
	SCREEN['b'].append(numpy.zeros((constants.WINDOW_HEIGHT, constants.WINDOW_WIDTH), dtype=numpy.int16))
	SCREEN['b'].append(numpy.zeros((constants.WINDOW_HEIGHT, constants.WINDOW_WIDTH), dtype=numpy.int16))
コード例 #12
0
def main_menu():
    libtcod.console_set_custom_font(
        'terminal8x12_gs_ro.png',
        libtcod.FONT_TYPE_GREYSCALE | libtcod.FONT_LAYOUT_ASCII_INROW)
    libtcod.console_init_root(cfg.SCREEN_WIDTH, cfg.SCREEN_HEIGHT,
                              'Monster Genetics', False)
    libtcod.sys_set_fps(cfg.LIMIT_FPS)
    img = libtcod.image_load('menu_background.png')

    while not libtcod.console_is_window_closed():
        gui.display_main_menu(img)

        #show options and wait for the player's choice
        choice = gui.menu('', [
            'Play a new game', 'Continue last game', 'Display controls', 'Quit'
        ], 24)

        if choice == 0:  #new game
            new_game()
            play_game()
        elif choice == 1:  #load last game
            try:
                load_game()
            except:
                gui.msgbox('\n No saved game to load.\n', 24)
                continue
            play_game()
        elif choice == 2:  #controls, will eventually be options menu
            gui.display_controls()
        elif choice == 3:  #quit
            break
コード例 #13
0
    def __init__(self):
        # Initialize libtcod root console
        libtcod.console_set_custom_font(
            'arial10x10.png',
            libtcod.FONT_TYPE_GREYSCALE | libtcod.FONT_LAYOUT_TCOD)
        self.root = libtcod.console_init_root(
            SCREEN_WIDTH,
            SCREEN_HEIGHT,
            'python dnd',
            False,
            renderer=libtcod.RENDERER_OPENGL2)

        # Create our own main console
        self.con = tcod.console.Console(SCREEN_WIDTH, SCREEN_HEIGHT)

        self.panel = tcod.console.Console(SCREEN_WIDTH, PANEL_HEIGHT)

        # Create the world
        world = World()

        world.populate_map()

        self.world = world

        self.game_time = GameTime()

        self.command_manager = CommandManager()
コード例 #14
0
ファイル: main.py プロジェクト: mscottmoore16/golemrl
def main():
    logging.basicConfig(filename='log.txt',level=logging.DEBUG,filemode='w')

    logging.debug('start of main')

    #initialize main console
    font_file = 'data/fonts/terminal10x10_gs_tc.png'
    libtcod.console_set_custom_font(font_file, libtcod.FONT_TYPE_GREYSCALE | libtcod.FONT_LAYOUT_TCOD)
    libtcod.console_init_root(SCREEN_W,SCREEN_H,'GolemRL')
    libtcod.sys_set_fps(LIMIT_FPS)

    key = libtcod.Key()
    mouse = libtcod.Mouse()

    while not libtcod.console_is_window_closed():
        libtcod.sys_check_for_event(libtcod.EVENT_ANY,key,mouse)
        choice = main_menu()
        if choice == 0:
            seed = random.randrange(10000)
            print 'Seed %i'%seed
            logging.info('Starting new game with seed %i' % seed)
            game = new_game()#seed)
            game.play()
        elif choice == 1:
            game = load_game()
            game.play()
        elif choice == 2:
            break

    logging.debug('end of main')
    return 0
コード例 #15
0
ファイル: main.py プロジェクト: Hideous/OfficeRL
def main():
	libtcod.console_set_custom_font('terminal8x8_gs_ro.png', libtcod.FONT_TYPE_GREYSCALE | libtcod.FONT_LAYOUT_INROW)
	libtcod.console_init_root(SCREEN_WIDTH, SCREEN_HEIGHT, 'OfficeRL', False)
	
	while not libtcod.console_is_window_closed():
		update()
		draw()
コード例 #16
0
ファイル: main.py プロジェクト: Makdaam/noi
def init_state():
    global state
    
#    state['seed'] = os.urandom(8)
    state['seed'] = 0
    random.seed(state['seed'])

    libtcod.console_set_custom_font('dejavu10x10_gs_tc.png', libtcod.FONT_TYPE_GREYSCALE | libtcod.FONT_LAYOUT_TCOD)
    libtcod.console_init_root(SCREEN_WIDTH, SCREEN_HEIGHT, 'python/libtcod tutorial', False)
    state['buffer']={}
    state['buffer']['map'] = libtcod.console_new(SCREEN_WIDTH, SCREEN_HEIGHT)
    con = state['buffer']['map']
    libtcod.console_set_default_foreground(con, libtcod.grey)
    libtcod.console_set_default_background(con, libtcod.black)


    state['maps'] = {}
    state['maps'][0] = make_map()
    state['maps'][1] = make_map()
    state['maps'][2] = make_map()
    state['maps'][3] = make_map()
    state['maps'][4] = make_map()

    state['entities']={}
    state['entities'][0] = list()
    state['entities'][1] = list()
    state['entities'][2] = list()
    state['entities'][3] = list()
    state['entities'][4] = list()

    generate_maps()

    state['current_level'] = 0
    state['player'] = Entity(START_X,START_Y,'@',libtcod.white)
コード例 #17
0
ファイル: worldMap.py プロジェクト: Lemmily/py-shopRL
def main():
    global key, mouse, map_, con
    
    R.SCREEN_WIDTH = 100
    R.SCREEN_HEIGHT = 80
    libtcod.console_set_custom_font("data\ont_big.png",libtcod.FONT_LAYOUT_ASCII_INROW)
    libtcod.console_init_root(R.SCREEN_WIDTH, R.SCREEN_HEIGHT, "Trader-RL", False)
    libtcod.sys_set_fps(R.LIMIT_FPS)        
    con = libtcod.console_new(R.SCREEN_WIDTH, R.SCREEN_HEIGHT)     
    
    
    map_ = Map(R.MAP_WIDTH,R.MAP_HEIGHT)        
    map_.wind_gen.run_simulation(500)
    
    mouse = libtcod.Mouse()
    key = libtcod.Key()
    
    while not libtcod.console_is_window_closed():
        libtcod.sys_check_for_event(libtcod.EVENT_KEY_PRESS|libtcod.EVENT_MOUSE, key, mouse)
        render()        
            
        
        player_action = handle_keys()
        if player_action == "exit":    
            break
        
        handle_mouse()
コード例 #18
0
    def __init__(self, screen_w, screen_h, view_w, view_h, fullscreen=False):
        self.fullscreen = fullscreen
        self.screen_w, self.screen_h = screen_w, screen_h
        self.view_w, self.view_h = view_w, view_h
        # Setup Font
        font_filename = 'res/arial12x12.png'
        tcod.console_set_custom_font(
            font_filename, tcod.FONT_TYPE_GREYSCALE | tcod.FONT_LAYOUT_TCOD)

        # Initialize screen
        title = 'Pyrouge'
        self.map_con = tcod.console_new(
            self.screen_w,
            self.screen_h)  # This needs to only be as big as the map can be
        self.log_con = tcod.console_new(self.view_w,
                                        self.screen_h - self.view_h)
        self.status_con = tcod.console_new(self.screen_w - self.view_w,
                                           self.screen_h // 2)
        self.equip_con = tcod.console_new(self.screen_w - self.view_w,
                                          self.screen_h // 2)
        tcod.console_init_root(self.screen_w, self.screen_h, title,
                               self.fullscreen)

        tcod.console_print_frame(self.status_con, 0, 0,
                                 self.screen_w - self.view_w,
                                 self.screen_h // 2, True, tcod.BKGND_NONE,
                                 'STATUS')
        tcod.console_print_frame(self.equip_con, 0, 0,
                                 self.screen_w - self.view_w,
                                 self.screen_h // 2, True, tcod.BKGND_NONE,
                                 'EQUIPMENT')

        self.msg_log = MessageLog(1, self.view_w - 2,
                                  self.screen_h - self.view_h - 2)
コード例 #19
0
ファイル: tcodui.py プロジェクト: svk/harmless7drl
 def __init__(self, debug = False):
     from harmless7drl import getCfg
     self.width = getCfg( "tcod", "width", 80, int )
     self.height = getCfg( "tcod", "height", 25, int )
     self.fps_limit = 20
     self.font_name = getCfg( "tcod", "font", "fonts/harmless-font-13x23.png" )
     self.font_layout = {
         "tcod":  libtcod.FONT_LAYOUT_TCOD,
         "ascii_incol":  libtcod.FONT_LAYOUT_ASCII_INCOL,
         "ascii_inrow":  libtcod.FONT_LAYOUT_ASCII_INROW,
     }[getCfg( "tcod", "fontlayout", "tcod" )]
     self.title = 'Harmless7DRL'
     self.colours = {
         'white': libtcod.white,
         'black': libtcod.black,
         'red': libtcod.red,
         'blue': libtcod.blue,
         'cyan': libtcod.cyan,
         'green': libtcod.green,
         'magenta': libtcod.magenta,
         'yellow': libtcod.yellow,
     }
     for key in self.colours.keys():
         self.colours["bold-"+key] = self.colours[key]
     for key in self.colours:
         if "bold" not in key:
             c = self.colours[key]
             self.colours[key] = libtcod.Color( c.r & 0x80, c.g & 0x80, c.b & 0x80 )
     from widgets import PrimaryColourRGB, SecondaryColourRGB, BorderColourRGB, HighlightPrimaryColourRGB, HighlightSecondaryColourRGB
     self.colours[ "tcod-primary" ] = libtcod.Color( *PrimaryColourRGB )
     self.colours[ "tcod-secondary" ] = libtcod.Color( *SecondaryColourRGB )
     self.colours[ "tcod-primary-hl" ] = libtcod.Color( *HighlightPrimaryColourRGB )
     self.colours[ "tcod-secondary-hl" ] = libtcod.Color( *HighlightSecondaryColourRGB )
     self.colours[ "tcod-border" ] = libtcod.Color( *BorderColourRGB )
     self.colours["bold-black"] = libtcod.Color( 0x80, 0x80, 0x80 )
     self.keymap = {
         libtcod.KEY_BACKSPACE: 'backspace',
         libtcod.KEY_KP1: 'southwest',
         libtcod.KEY_KP2: 'south',
         libtcod.KEY_KP3: 'southeast',
         libtcod.KEY_KP4: 'west',
         libtcod.KEY_KP6: 'east',
         libtcod.KEY_KP7: 'northwest',
         libtcod.KEY_KP8: 'north',
         libtcod.KEY_KP9: 'northeast',
         libtcod.KEY_END: 'southwest',
         libtcod.KEY_DOWN: 'south',
         libtcod.KEY_PAGEDOWN: 'southeast',
         libtcod.KEY_LEFT: 'west',
         libtcod.KEY_RIGHT: 'east',
         libtcod.KEY_HOME: 'northwest',
         libtcod.KEY_UP: 'north',
         libtcod.KEY_PAGEUP: 'northeast',
         libtcod.KEY_ENTER: '\n',
         libtcod.KEY_ESCAPE: 'escape',
     }
     libtcod.console_set_custom_font( self.font_name,
                                      libtcod.FONT_TYPE_GREYSCALE | self.font_layout)
     libtcod.console_init_root(self.width, self.height, self.title, False)
     libtcod.sys_set_fps( self.fps_limit )
コード例 #20
0
ファイル: renderer.py プロジェクト: survivaldev/rl
    def __init__(self,
                 screen_width: int = 80,
                 screen_height: int = 50,
                 font_path: str = "fonts/arial10x10.png",
                 game_fullscreen: bool = False):
        self.screen_width: int = screen_width
        self.screen_height: int = screen_height
        self.game_fullscreen: bool = game_fullscreen
        # other values are set to default
        self.game_size = 1
        self.game_font = Font.ARIAL
        self.display_icon: IconDisplay = IconDisplay.ICON
        # Creates libtcod root console
        libtcod.console_set_custom_font(fontFile=font_path,
                                        flags=libtcod.FONT_TYPE_GREYSCALE
                                        | libtcod.FONT_LAYOUT_TCOD)
        libtcod.console_init_root(w=self.screen_width,
                                  h=self.screen_height,
                                  title=GAME_NAME,
                                  fullscreen=self.game_fullscreen)
        # Console game scene
        self.consoles_scene: List[GameConsole] = list()

        # Default console values
        self.console_main: GameConsole = self.add_game_console(
            x=1,
            y=1,
            width=int(80 / 2),
            height=int(50 / 2),
            fore_fade=1,
            back_fade=1)
コード例 #21
0
    def __init__(self,
                 screen_width,
                 screen_height,
                 sidemenu_width,
                 infobar_height,
                 game_object,
                 margin_width=1,
                 game_font='assets/arial10x10.png'):
        self.screen_width = screen_width
        self.screen_height = screen_height
        self.margin_width = margin_width
        self.max_camera_width = self.screen_width - 2 * self.margin_width
        self.max_camera_height = self.screen_height - 2 * self.margin_width
        self.infobar_height = infobar_height
        self.sidemenu_width = sidemenu_width
        self.game_object = game_object

        self.paused = False
        self.loading = False
        self.cursor = None
        self.camera = None

        # Main console
        libtcod.console_set_custom_font(
            game_font, libtcod.FONT_TYPE_GREYSCALE | libtcod.FONT_LAYOUT_TCOD)
        libtcod.console_init_root(self.screen_width, self.screen_height,
                                  'Thermonuclear Go', False)
        # Libtcod consoles for GUI
        self.current_menu = MainMenu(screen_width, screen_height)
コード例 #22
0
def main():
    # Setup player

    # Setup Font
    font_filename = 'arial16x16.png'
    tcod.console_set_custom_font(
        f"./assets/{font_filename}",
        tcod.FONT_TYPE_GREYSCALE | tcod.FONT_LAYOUT_TCOD)

    # Initialize screen
    title = 'SkyMocha'
    global con
    con = tcod.console_init_root(SCREEN_WIDTH, SCREEN_HEIGHT, title,
                                 FULLSCREEN)

    # Set FPS
    tcod.sys_set_fps(LIMIT_FPS)

    SetScreenValues()
    # DrawFullMap(p_screen=-1)

    exit_game = False

    renderer = Thread(target=render_loop)
    renderer.start()

    flusher = Thread(target=flusher_loop)
    flusher.start()

    while not tcod.console_is_window_closed() and not exit_game:

        for event in tcod.event.get():
            if event.type == "KEYDOWN":
                exit_game = keyHandler(event.sym)
                sleep(cooldown * 0.95)
コード例 #23
0
ファイル: screen.py プロジェクト: gradberg/AsciiRailroad
def Initialize():
    libtcod.console_set_custom_font(
        'terminal12x12_gs_ro.png',
        libtcod.FONT_TYPE_GREYSCALE | libtcod.FONT_LAYOUT_ASCII_INROW)
    libtcod.console_init_root(SCREEN_WIDTH, SCREEN_HEIGHT, 'Rogue Locomotive',
                              False)
    libtcod.console_set_default_foreground(0, libtcod.white)
コード例 #24
0
def main():
    screen_width = 80
    screen_height = 80

    map_width = 80
    map_height = 70

    colors = {

        'dark_wall': libtcod.Color(45, 65, 100),
        'dark_ground': libtcod.Color(13, 23, 15)

    }


    player = Entity(int(screen_width / 2), int(screen_height / 2), '@', libtcod.white)
    entities = [player]

    libtcod.console_set_custom_font('arial10x10.png', libtcod.FONT_TYPE_GREYSCALE | libtcod.FONT_LAYOUT_TCOD)

    libtcod.console_init_root(screen_width, screen_height, 'table tosser', False)

    con = libtcod.console_new(screen_width, screen_height)

    game_map = GameMap(map_width, map_height)

    

    key = libtcod.Key()
    mouse = libtcod.Mouse()

    while not libtcod.console_is_window_closed():

        libtcod.sys_check_for_event(libtcod.EVENT_KEY_PRESS, key, mouse)


        render_all(con, entities, game_map, screen_width, screen_height, colors)


        libtcod.console_flush()
        
        clear_all(con, entities)

        action = handle_keys(key)

        move = action.get('move')
        exit = action.get('exit')
        fullscreen = action.get('fullscreen')

        if move:
            dx, dy = move
            if not game_map.is_blocked(player.x + dx, player.y +dy):
                player.move(dx, dy)

        if exit:
            return True

        if fullscreen:
            libtcod.console_set_fullscreen(not libtcod.console_is_fullscreen())
コード例 #25
0
ファイル: painter.py プロジェクト: NinjaEngineer/pyrogue
 def __init__(self):
     self.width = constants.WINDOW_WIDTH
     self.height = constants.WINDOW_HEIGHT
     self.console = libtcod.console_new(self.width, self.height)
     libtcod.console_set_custom_font(b'arial10x10.png',
                                     libtcod.FONT_TYPE_GREYSCALE |
                                     libtcod.FONT_LAYOUT_TCOD)
     libtcod.console_init_root(self.width, self.height, b'Pyrogue', False)
コード例 #26
0
    def __init__(self, width, height, fnt):
        self.SCREEN_WIDTH = width
        self.SCREEN_HEIGHT = height
        self.font = fnt

        libtcod.console_set_custom_font(self.font, libtcod.FONT_TYPE_GREYSCALE | libtcod.FONT_LAYOUT_TCOD)
        libtcod.console_init_root(self.SCREEN_WIDTH, self.SCREEN_HEIGHT, 'python/libtcod tutorial', False)
        self.con = libtcod.console_new(self.SCREEN_WIDTH, self.SCREEN_HEIGHT)
コード例 #27
0
ファイル: draw.py プロジェクト: cecilycarver/playground
def init_console():
    global con, gui_con, fov_recompute
    libtcod.console_set_custom_font(
        GAME_FONT, libtcod.FONT_TYPE_GREYSCALE | libtcod.FONT_LAYOUT_TCOD)
    libtcod.console_init_root(SCREEN_WIDTH, SCREEN_HEIGHT, WINDOW_TITLE, False)
    con = libtcod.console_new(SCREEN_WIDTH, SCREEN_HEIGHT)
    gui_con = libtcod.console_new(SCREEN_WIDTH, PANEL_HEIGHT)
    fov_recompute = True
コード例 #28
0
ファイル: painter.py プロジェクト: thespacepanda/pyrogue
 def __init__(self):
     self.width = constants.WINDOW_WIDTH
     self.height = constants.WINDOW_HEIGHT
     self.console = libtcod.console_new(self.width, self.height)
     libtcod.console_set_custom_font(b'arial10x10.png',
                                     libtcod.FONT_TYPE_GREYSCALE |
                                     libtcod.FONT_LAYOUT_TCOD)
     libtcod.console_init_root(self.width, self.height, b'Pyrogue', False)
コード例 #29
0
ファイル: game.py プロジェクト: dmiller113/Stay-in-the-Light
def programSetup():
    libtcod.console_set_custom_font(
        const.fontName, libtcod.FONT_TYPE_GREYSCALE | libtcod.FONT_LAYOUT_TCOD)
    libtcod.sys_set_fps(const.fps)
    libtcod.console_init_root(const.consoleWidth, const.consoleHeight,
                              'Stay in the Light')
    libtcod.console_set_default_foreground(const.root, libtcod.white)
    libtcod.console_clear(const.root)
    gEngine.drawUILines()
コード例 #30
0
def main():
    screen_width = 80
    screen_height = 50
    map_width = 80
    map_height = 45

    colors = {
        "dark_wall": libtcod.Color(0, 0, 100),
        "dark_ground": libtcod.Color(50, 50, 150)
    }

    player = Entity(int(screen_width / 2), int(screen_height / 2), "@",
                    libtcod.fuchsia)
    npc = Entity(int(screen_width / 2 - 5), int(screen_height / 2), "@",
                 libtcod.yellow)
    entities = [npc, player]

    # http://roguecentral.org/doryen/data/libtcod/doc/1.5.1/html2/console_set_custom_font.html?c=false&cpp=false&cs=false&py=true&lua=false
    libtcod.console_set_custom_font(
        "arial10x10.png",
        libtcod.FONT_TYPE_GREYSCALE | libtcod.FONT_LAYOUT_TCOD)
    # Creates the window, title, and fullscreen
    libtcod.console_init_root(screen_width, screen_height, "B@rd", False)

    # Draw a new console
    con = libtcod.console_new(screen_width, screen_height)

    game_map = GameMap(map_width, map_height)

    # Holds keyboard and mouse input
    key = libtcod.Key()
    mouse = libtcod.Mouse()

    # Game loop (until screen is closed)
    while not libtcod.console_is_window_closed():
        libtcod.sys_check_for_event(libtcod.EVENT_KEY_PRESS, key, mouse)

        render_all(con, entities, game_map, screen_width, screen_height,
                   colors)
        libtcod.console_flush()
        clear_all(con, entities)

        action = handle_keys(key)
        move = action.get("move")
        exit = action.get("exit")
        fullscreen = action.get("fullscreen")

        if move:
            dx, dy = move
            if not game_map.is_blocked(player.x + dx, player.y + dy):
                player.move(dx, dy)

        if exit:
            return True

        if fullscreen:
            libtcod.console_set_fullscreen(not libtcod.console_is_fullscreen())
コード例 #31
0
ファイル: gfx.py プロジェクト: flautines/rogueliketut
def start():
    libtcod.console_set_custom_font('arial10x10.png',
                                    libtcod.FONT_TYPE_GREYSCALE |
                                    libtcod.FONT_LAYOUT_TCOD)

    libtcod.console_init_root(SCREEN_WIDTH, SCREEN_HEIGHT,
                              'RogueLike with libtcod', False)

    back_buffer = libtcod.console_new(SCREEN_WIDTH, SCREEN_HEIGHT)
コード例 #32
0
ファイル: examplerl2.py プロジェクト: nrberens/Purge
def screen():
    global con, panel
    libtcod.console_set_custom_font('arial10x10.png', libtcod.FONT_TYPE_GREYSCALE | libtcod.FONT_LAYOUT_ASCII_INROW, 16,16)
    libtcod.console_set_custom_font('menu_background1.png', libtcod.FONT_TYPE_GREYSCALE | libtcod.FONT_LAYOUT_ASCII_INROW, 16,16)
    libtcod.console_init_root(SCREEN_WIDTH, SCREEN_HEIGHT, 'Try not to Die!', False)
    libtcod.sys_set_fps(LIMIT_FPS)
    con = libtcod.console_new(MAP_WIDTH, MAP_HEIGHT)
    panel = libtcod.console_new(SCREEN_WIDTH, PANEL_HEIGHT)
    objects = []
コード例 #33
0
ファイル: engine.py プロジェクト: haveric/roguelikedev
def main():
	screen_width = 80
	screen_height = 50
	map_width = 80
	map_height = 45
	
	room_max_size = 10
	room_min_size = 6
	max_rooms = 30
	
	colors = {
		'dark_wall': libtcod.Color(0, 0, 100),
		'dark_ground': libtcod.Color(50, 50, 150)
	}
	
	player = Entity(int(screen_width / 2), int(screen_height / 2), '@', libtcod.white)
	npc = Entity(int(screen_width / 2), int(screen_height / 2), '@', libtcod.yellow)
	entities = [npc, player]
	
	libtcod.console_set_custom_font('arial10x10.png', libtcod.FONT_TYPE_GREYSCALE | libtcod.FONT_LAYOUT_TCOD)
	
	libtcod.console_init_root(screen_width, screen_height, 'libtcod tutorial revised', False)
	
	con = libtcod.console_new(screen_width, screen_height)
	
	game_map = GameMap(map_width, map_height)
	game_map.make_map(max_rooms, room_min_size, room_max_size, map_width, map_height, player)
	
	key = libtcod.Key()
	mouse = libtcod.Mouse()
	
	while not libtcod.console_is_window_closed():
		libtcod.sys_check_for_event(libtcod.EVENT_KEY_PRESS, key, mouse)
	
		render_all(con, entities, game_map, screen_width, screen_height, colors)
		
		libtcod.console_flush()
		
		clear_all(con, entities)
		
		action = handle_keys(key)
		
		move = action.get('move')
		exit = action.get('exit')
		fullscreen = action.get('fullscreen')
		
		if move:
			dx, dy = move
			if not game_map.is_blocked(player.x + dx, player.y + dy):
				player.move(dx, dy)
		
		if exit:
			return True
			
		if fullscreen:
			libtcod.console_set_fullscreen(not libtcod.console_is_fullscreen())
コード例 #34
0
ファイル: Screen.py プロジェクト: romanlevin/pyrogue
 def __init__(self, screen_width, screen_height, map_width, map_height, fps_limit, start_fullscreen, font):
     libtcod.console_set_custom_font(font, libtcod.FONT_TYPE_GREYSCALE | libtcod.FONT_LAYOUT_TCOD)
     libtcod.console_init_root(screen_width, screen_height, 'pyrogue', start_fullscreen)
     self.screen_width = screen_width
     self.screen_height = screen_height
     self.fps_limit = fps_limit
     self.console = libtcod.console_new(screen_width, screen_height)
     self.state = State(map_width, map_height)
     self.fov_recompute = True
     self.mode = 'playing'
コード例 #35
0
def initialize_console(font, dimensions, window_title, fps=20):
    """Creates the console window"""
    #Derive width and height
    width = dimensions[0]
    height = dimensions[1]
    #Initialize console
    lib.console_set_custom_font(font,
                                lib.FONT_TYPE_GREYSCALE | lib.FONT_LAYOUT_TCOD)
    lib.console_init_root(width, height, window_title, False)
    lib.sys_set_fps(fps)
コード例 #36
0
ファイル: game.py プロジェクト: dmiller113/Stay-in-the-Light
def programSetup():
    libtcod.console_set_custom_font(
        const.fontName,
        libtcod.FONT_TYPE_GREYSCALE | libtcod.FONT_LAYOUT_TCOD)
    libtcod.sys_set_fps(const.fps)
    libtcod.console_init_root(const.consoleWidth, const.consoleHeight,
                              'Stay in the Light')
    libtcod.console_set_default_foreground(const.root, libtcod.white)
    libtcod.console_clear(const.root)
    gEngine.drawUILines()
コード例 #37
0
ファイル: settings.py プロジェクト: samuwen/pyrogue
def init():
	font_path = 'assets/fonts/arial10x10.png'
	font_flags = tcod.FONT_TYPE_GREYSCALE | tcod.FONT_LAYOUT_TCOD
	tcod.console_set_custom_font(font_path, font_flags)

	window_title = "Roguelike"
	fullscreen = False
	tcod.console_init_root(SCREEN_WIDTH, SCREEN_HEIGHT, window_title, fullscreen)

	tcod.sys_set_fps(LIMIT_FPS)
コード例 #38
0
   def __init__(self):
      # Console information
      self.width = CONSOLE_WIDTH
      self.height = CONSOLE_HEIGHT
      
      # Font information
      libtcod.console_set_custom_font('dejavu16x16_gs_tc.png', libtcod.FONT_TYPE_GREYSCALE | libtcod.FONT_LAYOUT_TCOD)
      
      # Initialize root console
      libtcod.console_init_root(self.width, self.height, 'Destard', False)
      
      # Renderer method
      #libtcod.sys_set_renderer(libtcod.RENDERER_SDL)

      # Map info.  MapFactory is the map construction object.  Maybe this should be generic so that new levels can be built.
      MapFactory = map.new_caf()
      self.map = map.new_map(self, MapFactory)
      self.rooms = map.get_rooms(MapFactory)
      self.level = 1

      # Objects
      self.objects = []
      lightsource_component = actors.LightSource(self, "torch", mobile=True)
      mover_component = actors.Mover()
      self.player = actors.Object(5, 5, '@', 'player', libtcod.white, blocks=True, lightsource=lightsource_component, mover=mover_component)
      self.objects.append(self.player)
      lightsource_component = actors.LightSource(self, "brazier")
      temptorch = actors.Object(14, 12, 'X', 'brazier', libtcod.black, blocks=True, lightsource=lightsource_component)
      self.objects.append(temptorch)

      map.place_player(self, MapFactory)
      #map.fill_rooms
      
      # This is the 'painting' console.  Map height and width are set up by the map gen.
      self.canvas_width = self.map_width
      self.canvas_height = self.map_height
      self.canvas = libtcod.console_new(self.canvas_width, self.canvas_height)
      libtcod.console_set_default_background(self.canvas, libtcod.black)
      libtcod.console_clear(self.canvas)
      
      # FOV map for rendering purposes.
      self.map_movement = True
      self.map_change = True
      self.fov_map = map.new_fov_map(self)
      
      # Torch info.  Should be replaced with torch object held by player or defaulting to some small value.
      #self.torch_radius = 20
      #self.torch_flicker_exponent = 1
      #self.torch_flicker_style = 'Random'

      # Game state information
      self.state = 'playing'

      # Debug setting.  Other functions will use this for debug info.  HOPEFULLY
      self.debug = DEBUG
コード例 #39
0
def main():
    # Setup player
    global player_x, player_y, player_cor, snake_len, fruit_x, fruit_y, high_score
    player_x = SCREEN_WIDTH // 2
    player_y = SCREEN_HEIGHT // 2
    player_cor = []
    snake_len = 0
    high_score = 0
    fruit_x = randint(0, 80)
    fruit_y = randint(0, 50)
    game_over = "u lost"

    # Setup Font
    font_filename = 'arial10x10.png'
    tcod.console_set_custom_font(
        font_filename, tcod.FONT_TYPE_GREYSCALE | tcod.FONT_LAYOUT_TCOD)

    # Initialize screen
    title = 'Snake'
    root = tcod.console_init_root(SCREEN_WIDTH, SCREEN_HEIGHT, title,
                                  FULLSCREEN)

    # Set FPS
    tcod.sys_set_fps(LIMIT_FPS)

    exit_game = False
    while not tcod.console_is_window_closed() and not exit_game:
        tcod.console_set_default_foreground(0, tcod.white)
        tcod.console_put_char(0, player_x, player_y, '@', tcod.BKGND_NONE)
        tcod.console_flush()

        if player_x == fruit_x and player_y == fruit_y:
            snake_len += 1
            high_score += 1

        place_fruit()
        snake()
        handle_keys()

        if tcod.console_get_char(0, player_x, player_y) == 49:
            sleep(1)
            tcod.console_clear(root)
            tcod.console_flush()
            sleep(0.5)
            tcod.console_print_rect_ex(root, (SCREEN_WIDTH // 2) -
                                       len(game_over) // 2, SCREEN_HEIGHT // 2,
                                       0, 0, 0, 0, "{}".format(game_over))
            tcod.console_print_rect_ex(
                root, (SCREEN_WIDTH // 2) -
                len("Highscore: {}".format(high_score)) // 2,
                (SCREEN_HEIGHT // 2) + 2, 0, 0, 0, 0,
                "Highscore: {}".format(high_score))
            tcod.console_flush()
            sleep(5)
            sys.exit()
コード例 #40
0
def main():
    screen_width = 80
    screen_height = 50

    player_x = int(screen_width / 2)
    player_y = int(screen_height / 2)

    libtcod.console_set_custom_font(
        'arial10x10.png',
        libtcod.FONT_TYPE_GREYSCALE | libtcod.FONT_LAYOUT_TCOD)
    # imports font, tells libtcod how to interpret font png

    libtcod.console_init_root(screen_width, screen_height,
                              'libtcod tutorial revised', False)
    # creates main screen (width, height, title, fullscreen T/F)

    con = libtcod.console_new(screen_width, screen_height)

    key = libtcod.Key()
    # captures keyboard input
    mouse = libtcod.Mouse()
    # captures mouse input

    while not libtcod.console_is_window_closed():
        # keeps game running as long as window is open

        libtcod.sys_check_for_event(libtcod.EVENT_KEY_PRESS, key, mouse)
        # checks for mouse or keyboard input

        libtcod.console_set_default_foreground(con, libtcod.white)
        libtcod.console_put_char(con, player_x, player_y, '@',
                                 libtcod.BKGND_NONE)
        libtcod.console_blit(con, 0, 0, screen_width, screen_height, 0, 0, 0)

        libtcod.console_flush()
        # flushes everything to printout

        libtcod.console_put_char(con, player_x, player_y, ' ',
                                 libtcod.BKGND_NONE)

        action = handle_keys(key)
        move = action.get('move')
        exit = action.get('exit')
        fullscreen = action.get('fullscreen')

        if move:
            dx, dy = move
            player_x += dx
            player_y += dy

        if exit:
            return True

        if fullscreen:
            libtcod.console_set_fullscreen(not libtcod.console_is_fullscreen())
コード例 #41
0
ファイル: game.py プロジェクト: mob96/SnakeLike
def main():
    #Initialise some game variables/objects and the libtcod console
    screen_width = 16
    screen_height = 16
    fps_limit = 60

    libtcod.console_set_custom_font(
        'arial10x10.png',
        libtcod.FONT_TYPE_GREYSCALE | libtcod.FONT_LAYOUT_TCOD)
    libtcod.console_init_root(screen_width, screen_height, 'Snake', False)
    libtcod.sys_set_fps(fps_limit)

    con = libtcod.console_new(screen_width, screen_height)
    key = libtcod.Key()
    mouse = libtcod.Mouse()
    apple = Apple('A', libtcod.Color(200, 20, 20), screen_width, screen_height)
    snake = Snake(int(screen_width / 2), int(screen_height / 2), 'S',
                  libtcod.Color(20, 200, 20), 1, fps_limit, apple,
                  screen_width, screen_height)

    #Main game loop
    while not libtcod.console_is_window_closed():
        #Updates game entities if snake is not dead
        if snake.alive == True:
            snake.update()
            entities = snake.entities.copy()
            entities.append(apple.apple)

        #Handles rendering
        render_all(con, entities, screen_width, screen_height)
        libtcod.console_flush()
        clear_all(con, entities)

        #Handles keyboard input
        libtcod.sys_check_for_event(libtcod.EVENT_KEY_PRESS, key, mouse)
        input = handle_keys(key)
        move = input.get('move')
        restart = input.get('restart')
        exit = input.get('exit')
        fullscreen = input.get('fullscreen')

        if move:
            snake.set_next_dir(move)

        if restart:
            snake = Snake(int(screen_width / 2), int(screen_height / 2), 'S',
                          libtcod.Color(20, 200, 20), 1, fps_limit, apple,
                          screen_width, screen_height)

        if exit:
            return True

        if fullscreen:
            libtcod.console_set_fullscreen(not libtcod.console_is_fullscreen())
コード例 #42
0
ファイル: graphics.py プロジェクト: NinjaEngineer/pyrogue
 def __init__(self, entities=[], SCREEN_WIDTH=80, SCREEN_HEIGHT=50):
     self.entities = entities
     self.SCREEN_WIDTH = SCREEN_WIDTH
     self.SCREEN_HEIGHT = SCREEN_HEIGHT
     self.console = libtcod.console_new(self.SCREEN_WIDTH,
                                        self.SCREEN_HEIGHT)
     libtcod.console_set_custom_font(b'arial10x10.png',
                                     libtcod.FONT_TYPE_GREYSCALE |
                                     libtcod.FONT_LAYOUT_TCOD)
     libtcod.console_init_root(self.SCREEN_WIDTH, self.SCREEN_HEIGHT,
                               b'python/libtcod tutorial', False)
コード例 #43
0
def init_ui():
    global console
    tcod.console_set_custom_font(
        'data/terminal10x16_gs_tc.png',
        tcod.FONT_TYPE_GRAYSCALE | tcod.FONT_LAYOUT_TCOD)
    tcod.console_init_root(SCREEN_WIDTH, SCREEN_HEIGHT,
                           'libtcod tutorial revisited', False)
    console = tcod.console_new(SCREEN_WIDTH, SCREEN_HEIGHT)
    popup = tcod.console_new(SCREEN_WIDTH, SCREEN_HEIGHT)
    message_log = MessageLog(MAX_MAP_WIDTH, SCREEN_HEIGHT - MAX_MAP_HEIGHT - 1)
    return message_log, tcod.Key(), tcod.Mouse()
コード例 #44
0
ファイル: init.py プロジェクト: zhaozhixiangz/TheLastRogue
def init_libtcod():
    libtcod.console_set_custom_font(FONT_FILE_PATH,
                                    libtcod.FONT_LAYOUT_ASCII_INROW |
                                    libtcod.FONT_TYPE_GREYSCALE,
                                    16, 34)
    libtcod.console_init_root(settings.SCREEN_WIDTH,
                              settings.SCREEN_HEIGHT,
                              b'The Last Rogue',
                              settings.FULL_SCREEN)
    fps = settings.FPS
    libtcod.sys_set_fps(fps)
コード例 #45
0
ファイル: ui.py プロジェクト: jlcordeiro/mprl
    def __init__(self):
        flags = libtcod.FONT_TYPE_GREYSCALE | libtcod.FONT_LAYOUT_TCOD
        libtcod.console_set_custom_font(self.font, flags)
        libtcod.console_init_root(SCREEN_WIDTH, SCREEN_HEIGHT, 'mprl', False)
        libtcod.sys_set_fps(LIMIT_FPS)

        self.con = libtcod.console_new(MAP_WIDTH, MAP_HEIGHT)
        self.panel = libtcod.console_new(SCREEN_WIDTH, PANEL_HEIGHT)
        self.inv_window = libtcod.console_new(MAP_WIDTH, MAP_HEIGHT)

        self.hp_bar = UIBar('HP', libtcod.darker_red, libtcod.light_red)
コード例 #46
0
ファイル: firstrl.py プロジェクト: MykeMcG/SummerRoguelike
def init():
    global Console, Stats_Panel
    libtcod.sys_set_fps(consts.FPS_LIMIT)
    libtcod.console_set_custom_font(
        consts.TILESET, libtcod.FONT_TYPE_GREYSCALE
        | libtcod.FONT_LAYOUT_ASCII_INROW)
    libtcod.console_init_root(consts.SCREEN_WIDTH, consts.SCREEN_HEIGHT,
                              consts.GAME_TITLE, False)
    Console = libtcod.console_new(consts.SCREEN_WIDTH, consts.SCREEN_HEIGHT)

    Stats_Panel = libtcod.console_new(consts.SCREEN_WIDTH, consts.PANEL_HEIGHT)
    main_menu()
コード例 #47
0
def main():
    screen_width = 80
    screen_height = 50

    key = libtcod.Key()
    mouse = libtcod.Mouse()
    
    libtcod.console_set_custom_font('arial10x10.png', libtcod.FONT_TYPE_GREYSCALE | libtcod.FONT_LAYOUT_TCOD)
    libtcod.console_init_root(screen_width, screen_height, 'Oh, Sheep!', False)

    con = libtcod.console_new(screen_width, screen_height)
    panel = libtcod.console_new(screen_width, panel_height)
コード例 #48
0
ファイル: Dungeoneer.py プロジェクト: cjones/dungeoneer
def game_initialize():
    libtcod.console_set_custom_font('oryx_tiles3.png', libtcod.FONT_TYPE_GREYSCALE | libtcod.FONT_LAYOUT_TCOD, 32, 12)
    libtcod.console_init_root(data.SCREEN_WIDTH, data.SCREEN_HEIGHT, 'MeFightRogues!', False, libtcod.RENDERER_SDL)
    libtcod.sys_set_fps(data.LIMIT_FPS)

    libtcod.console_map_ascii_codes_to_font(256   , 32, 0, 5)  #map all characters in 1st row
    libtcod.console_map_ascii_codes_to_font(256+32, 32, 0, 6)  #map all characters in 2nd row

    Game.con = libtcod.console_new(data.MAP_WIDTH,data.MAP_HEIGHT)
    Game.panel = libtcod.console_new(data.SCREEN_WIDTH, data.PANEL_HEIGHT)

    main_menu()
コード例 #49
0
ファイル: engine.py プロジェクト: ostcrom/roguelike
def main():

    libtcod.console_set_custom_font('arial10x10.png', libtcod.FONT_TYPE_GREYSCALE | libtcod.FONT_LAYOUT_TCOD)

    libtcod.console_init_root(screen_width, screen_height, 'libtcod tutorial revised', False)
    con = libtcod.console_new(screen_width, screen_height)
    dialog_prompt = DialogPrompt(dialog_pos_x, dialog_pos_y, "npc_dialog", dialog_width, dialog_height, con)

    game_map = GameMap(map_width, map_height)
    game_map.switch_map(0)

    fov_recomputer = True


    game_entities = []
    dialog_entities = []
    player = GameObject(3, 3, '@', libtcod.white, "Hero", True)
    npc = GameObject(int(screen_width / 2 - 5), int(screen_height / 2), '@', libtcod.yellow, "Bad Guy", True)
    game_entities.append(player)
    game_entities.append(npc)
    key= libtcod.Key()
    mouse = libtcod.Mouse()
    libtcod.console_set_window_title(game_title+ " - " + game_map.map_name)
    while not libtcod.console_is_window_closed():
        libtcod.sys_check_for_event(libtcod.EVENT_KEY_PRESS, key, mouse)
        draw_all(con, game_entities, game_map, screen_width, screen_height)
        libtcod.console_flush()
        clear_all(con, game_entities)
        if key.c == ord('a'):
            dialog_prompt.npc_dialog('main')
        action = handle_keys(key)

        move = action.get('move')
        exit = action.get('exit')

        if move:
            dx, dy = move

            if not game_map.is_blocked(player.x + dx, player.y + dy) and not game_map.is_transport(player.x + dx, player.y + dy):
                game_map.unblock(player.x, player.y)
                player.move(dx,dy)
            elif game_map.is_transport(player.x + dx, player.y + dy):
                transport = game_map.spaces[player.x + dx][player.y + dy].transport
                game_map.switch_map(transport.new_map_index)
                libtcod.console_set_window_title( game_title + " - " + game_map.map_name)
                game_map.unblock(player.x, player.y)
                player.move(dx , dy )
                player.move(transport.dx, transport.dy)


        if key.vk == libtcod.KEY_ESCAPE:
            return True
        game_map.update_blocked(game_entities)
コード例 #50
0
ファイル: renderer.py プロジェクト: survivaldev/rl
 def update_root_console(self):
     # libtcod.console_delete(0)
     libtcod.sys_shutdown()
     font_path = "fonts/" + GAME_FONTS.get(self.game_font,
                                           [])[self.game_size]
     libtcod.console_set_custom_font(fontFile=font_path,
                                     flags=libtcod.FONT_TYPE_GREYSCALE
                                     | libtcod.FONT_LAYOUT_TCOD)
     libtcod.console_init_root(w=self.screen_width,
                               h=self.screen_height,
                               title=GAME_NAME,
                               fullscreen=self.game_fullscreen)
コード例 #51
0
ファイル: game.py プロジェクト: GeorgeShannon/Destard
    def __init__(self):
        # Console information
        self.width = CONSOLE_WIDTH
        self.height = CONSOLE_HEIGHT
        self.objects = []

        # Font information
        libtcod.console_set_custom_font('fonts/prestige12x12_gs_tc.png', libtcod.FONT_TYPE_GREYSCALE | libtcod.FONT_LAYOUT_TCOD)
        #libtcod.console_set_custom_font('fonts/dejavu_wide12x12_gs_tc.png', libtcod.FONT_TYPE_GREYSCALE | libtcod.FONT_LAYOUT_TCOD)
        #libtcod.console_set_custom_font('fonts/terminal16x16_gs_ro.png', libtcod.FONT_TYPE_GREYSCALE | libtcod.FONT_LAYOUT_ASCII_INROW)

        # Initialize root console
        libtcod.console_init_root(self.width, self.height, 'Destard', False)

        # Renderer method
        #libtcod.sys_set_renderer(libtcod.RENDERER_SDL)

        # Map info.  Level is the map construction object - Maybe this should be generic so that new levels can be built.
        self.level = map.new_level(1)
        self.map = map.get_map_from_level(self)
        self.objects = map.get_objects_from_level(self)
        #self.rooms = self.factory.get_rooms(self.map)

        # Objects
        lightsource_component = actors.LightSource(self.map, "torch", mobile=True)
        mover_component = actors.Mover()
        self.player = actors.Object(5, 5, '@', 'player', libtcod.white, blocks=True, lightsource=lightsource_component, mover=mover_component)
        self.objects.append(self.player)
        map.initial_place_player(self)

        # This is the 'painting' console.  Map height and width are set up by the map gen.
        self.canvas_width = self.map_width
        self.canvas_height = self.map_height
        self.canvas = libtcod.console_new(self.canvas_width, self.canvas_height)
        libtcod.console_set_default_background(self.canvas, libtcod.black)
        libtcod.console_clear(self.canvas)

        # FOV map for rendering purposes.
        self.map_movement = True
        self.map_change = True
        self.fov_map = map.new_fov_map(self.map)
      
        # Torch info.  Should be replaced with torch object held by player or defaulting to some small value.
        #self.torch_radius = 20
        #self.torch_flicker_exponent = 1
        #self.torch_flicker_style = 'Random'

        # Game state information
        self.state = 'playing'

        # Debug setting.  Other functions will use this for debug info.  HOPEFULLY
        self.debug_showexplored = False
        self.debug_troubletiles = False
コード例 #52
0
def renderer_init():
    """
    Initialize libtcod and set up our basic consoles to draw into.
    """
    global _con, _panel, _overlay, _last_frame_time
    libtcod.console_set_custom_font('arial12x12.png', libtcod.FONT_TYPE_GREYSCALE | libtcod.FONT_LAYOUT_TCOD)
    libtcod.console_init_root(config.SCREEN_WIDTH, config.SCREEN_HEIGHT, 'python/libtcod tutorial', False)
    libtcod.sys_set_fps(LIMIT_FPS)
    _con = libtcod.console_new(config.MAP_PANEL_WIDTH, config.MAP_PANEL_HEIGHT)
    _overlay = libtcod.console_new(config.MAP_PANEL_WIDTH, config.MAP_PANEL_HEIGHT)
    _panel = libtcod.console_new(config.SCREEN_WIDTH, config.PANEL_HEIGHT)
    _last_frame_time = time.time() * 1000
コード例 #53
0
ファイル: DalekRL.py プロジェクト: frogbotherer/DalekRL
def init():
    # init window
    font = os.path.join(b'resources', b'consolas10x10_gs_tc.png')
    libtcod.console_set_custom_font(font, libtcod.FONT_TYPE_GREYSCALE | libtcod.FONT_LAYOUT_TCOD)
    libtcod.console_init_root(SCREEN_SIZE.x, SCREEN_SIZE.y, b'DalekRL')
    libtcod.sys_set_fps(LIMIT_FPS)

    # set default text palette # TODO: merge with UI class statics
    libtcod.console_set_color_control(libtcod.COLCTRL_1,libtcod.red,libtcod.black)
    libtcod.console_set_color_control(libtcod.COLCTRL_2,libtcod.dark_yellow,libtcod.black)
    libtcod.console_set_color_control(libtcod.COLCTRL_3,libtcod.light_green,libtcod.black)
    libtcod.console_set_color_control(libtcod.COLCTRL_4,libtcod.light_blue,libtcod.black)
    libtcod.console_set_color_control(libtcod.COLCTRL_5,libtcod.purple,libtcod.black)
コード例 #54
0
ファイル: Hello.py プロジェクト: UrsaOK/supertassu
def main():

    #actual size of the window
    SCREEN_WIDTH = 80
    SCREEN_HEIGHT = 50
     
    LIMIT_FPS = 20  #20 frames-per-second maximum

    raw_input("[INFO] Paina ENTER startataksesi.")

    libtcod.console_set_custom_font('arial10x10.png', libtcod.FONT_TYPE_GREYSCALE | libtcod.FONT_LAYOUT_TCOD)
     
    libtcod.console_init_root(SCREEN_WIDTH, SCREEN_HEIGHT, 'ROQUELIKE', False)
     
    libtcod.sys_set_fps(LIMIT_FPS)

    taso = Taso(0)
    pelaaja = Liikkuja(1, 1, '@', taso)

    print("[DEBUG] LOOPPI ALKAA")

    while not libtcod.console_is_window_closed():
     
        libtcod.console_set_default_foreground(0, libtcod.white)

        print("[DEBUG] DRAW FUNKTIOTA KUTSUTAAN")

        taso.kartta.draw(0)

        pelaaja.draw(0)
        libtcod.console_flush()

        print("[DEBUG] odotetaan nappulaa")

        nappula = libtcod.console_wait_for_keypress(True)

        print("[DEBUG] Nappula saatu")

        if nappula.vk == libtcod.KEY_ESCAPE:
            return
        elif nappula.vk == libtcod.KEY_RIGHT:
            pelaaja.liiku((1, 0))
        elif nappula.vk == libtcod.KEY_LEFT:
            pelaaja.liiku((-1, 0))
        elif nappula.vk == libtcod.KEY_UP:
            pelaaja.liiku((0, -1))
        elif nappula.vk == libtcod.KEY_DOWN:
            pelaaja.liiku((0, 1))
        else:
            print("tuntematon nappain, ei virheita")
コード例 #55
0
ファイル: libbluebox.py プロジェクト: jarcane/BlueBox
    def change_resolution(self, target_width, target_height=24):
        # wipes the screen and changes the text mode to the target
        self.width = target_width
        self.height = target_height
        if self.width == 80:
            libtcod.console_set_custom_font('bluebox80.png',
                                            libtcod.FONT_TYPE_GREYSCALE | libtcod.FONT_LAYOUT_ASCII_INROW)
        else:
            libtcod.console_set_custom_font('bluebox.png',
                                            libtcod.FONT_TYPE_GREYSCALE | libtcod.FONT_LAYOUT_ASCII_INROW)
        libtcod.console_init_root(self.width, self.height, self.win_name, False)

        # reinitialize self.screen
        self.screen = [[' ' for y in range(self.height)] for x in range(self.width)]
        self.clear_screen()
コード例 #56
0
ファイル: main.py プロジェクト: Lemmily/py-shopRL
def main_init():
    global con, con_char, inf,minmap, message_bar, date, ui, game_msgs
    #libtcod.console_set_custom_font("dejavu16x16.png", libtcod.FONT_TYPE_GREYSCALE | libtcod.FONT_LAYOUT_TCOD)
    libtcod.console_set_custom_font("data\ont_big.png",libtcod.FONT_LAYOUT_ASCII_INROW)
    libtcod.console_init_root(R.SCREEN_WIDTH, R.SCREEN_HEIGHT, "Trader-RL", False)
    libtcod.sys_set_fps(R.LIMIT_FPS)
    con = R.con = libtcod.console_new(R.MAP_WIDTH, R.MAP_HEIGHT)
    con_char = R.con_char = libtcod.console_new(R.MAP_WIDTH, R.MAP_HEIGHT)
    inf = R.inf = libtcod.console_new(R.INFO_BAR_WIDTH, R.SCREEN_HEIGHT - R.PANEL_HEIGHT)
    minmap = R.minmap = libtcod.console_new(R.INFO_BAR_WIDTH, R.PANEL_HEIGHT)
    message_bar = R.message_bar = libtcod.console_new(R.PANEL_WIDTH, R.PANEL_HEIGHT)
    
    game_msgs = R.game_msgs = []
    ui = R.ui = UI.UI(con,game_msgs)
    date = R.date = [0, [DAYS[0][0], 1, 1], [MONTHS[0][0], 1, 31], 1000];