Beispiel #1
0
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
Beispiel #2
0
  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
Beispiel #3
0
 def __init__(self, width, height):
     self.screen_width = width
     self.screen_height = height
     self.assets = []
     
     tcod.console_init_root(self.screen_width, self.screen_height, 'Wicked Cool Shit', False)
     self.con = tcod.console_new(self.screen_width, self.screen_height)
Beispiel #4
0
    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 = []
Beispiel #5
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
Beispiel #6
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)
Beispiel #7
0
  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()
Beispiel #8
0
    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
Beispiel #9
0
	def __init__(self, app_name='test app', screen_width=None, screen_height=None):
		print '__init__'
		if screen_width is None:
			screen_width, screen_height = self.SCREEN_WIDTH, self.SCREEN_HEIGHT
		libtcod.console_init_root(
			screen_width, screen_height, app_name, False
		)

		self.game_msgs = []
		global message
		message = self.message

		self.game_state = 'playing'
		self.player_action = 'didnt-take-turn'

		x,y = None,None

		self.con = libtcod.console_new(self.MAP_WIDTH, self.MAP_HEIGHT)
		self.panel = libtcod.console_new(self.SCREEN_WIDTH, self.PANEL_HEIGHT)
		self.cursor = Cursor(self.con, 'X', 0,0)

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

		libtcod.sys_set_fps(self.LIMIT_FPS)
Beispiel #10
0
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)
Beispiel #11
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)
Beispiel #12
0
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()
Beispiel #13
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()
Beispiel #14
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)
Beispiel #15
0
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))
Beispiel #16
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()
Beispiel #17
0
 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 )
Beispiel #18
0
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)
Beispiel #19
0
    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)
Beispiel #20
0
    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 = ''
Beispiel #21
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)
Beispiel #22
0
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)
Beispiel #23
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())
Beispiel #24
0
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
Beispiel #25
0
 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)
Beispiel #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)
Beispiel #27
0
 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)
Beispiel #28
0
 def init(self): #init tcod & such
     global turn_log
     tcod.console_init_root(GAME_WIDTH,GAME_HEIGHT,'deth')
     tcod.console_set_default_background(0, tcod.darkest_gray)
     tcod.sys_set_fps(15)
     
     turn_log = '\b'
     
     self.menu()
Beispiel #29
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())
Beispiel #30
0
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()
    def __init__(self, screen_width=120, screen_height=70):
        self.screen_width = screen_width
        self.screen_height = screen_height

        libtcod.console_init_root(self.screen_width, self.screen_height, 'Heliopause', False)

        self.buffer = libtcod.ConsoleBuffer(self.screen_width, self.screen_height)
        self.console = libtcod.console_new(self.screen_width, self.screen_height)

        self.galaxy_map_console = libtcod.console_new(self.screen_width, self.screen_height)

        self.set_minimap(20)

        self.targeting_width = 20
        self.targeting_height = 26
        self.targeting_buffer  = libtcod.ConsoleBuffer(self.targeting_width, self.targeting_height)
        self.targeting_console = libtcod.console_new(self.targeting_width, self.targeting_height)
        libtcod.console_set_default_foreground(self.targeting_console, libtcod.white)
        libtcod.console_set_default_background(self.targeting_console, libtcod.black)

        self.ship_info_width = 20
        self.ship_info_height = 8
        self.ship_info_buffer  = libtcod.ConsoleBuffer(self.ship_info_width, self.ship_info_height)
        self.ship_info_console = libtcod.console_new(self.ship_info_width, self.ship_info_height)
        libtcod.console_set_default_foreground(self.ship_info_console, libtcod.white)
        libtcod.console_set_default_background(self.ship_info_console, libtcod.black)

        self.message_height = 4
        self.message_width = self.screen_width
        self.messages = collections.deque([])
        self.message_console = libtcod.console_new(self.message_width, self.message_height)
        libtcod.console_set_default_foreground(self.message_console, libtcod.white)
        libtcod.console_set_default_background(self.message_console, libtcod.black)

        self.landing_screen_width = self.screen_width / 2 - 2
        self.landing_screen_height = self.screen_height - 4
        self.landing_console = libtcod.console_new(self.landing_screen_width, self.landing_screen_height)
        libtcod.console_set_default_foreground(self.landing_console, libtcod.white)
        libtcod.console_set_default_background(self.landing_console, libtcod.black)

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

        galaxy_seed, ship_value = self.title_screen_loop()

        # Loading Screen
        libtcod.console_set_default_background(self.console, libtcod.black)
        libtcod.console_clear(self.console)

        self.galaxy = Galaxy(self.screen_width, self.screen_height, seed=galaxy_seed)
        self.sector, self.starfield, self.nebula = self.galaxy.sectors[self.galaxy.current_sector].load_sector(self.console, self.buffer)

        starting_planet = self.sector.planets[randrange(1, len(self.sector.planets))]
        self.player_ship = Ship(self.sector, starting_planet.sector_position_x, starting_planet.sector_position_y, ship_value=ship_value)
        self.add_message("Taking off from {0}".format(starting_planet.name))

        self.current_screen = 'flight'
Beispiel #32
0
 def toggle_fullscreen(self):
     self.game_fullscreen = not self.game_fullscreen
     # libtcod.console_set_fullscreen(self.game_fullscreen)
     # libtcod.console_delete(0)
     libtcod.sys_shutdown()
     libtcod.console_init_root(w=self.screen_width,
                               h=self.screen_height,
                               title=GAME_NAME,
                               fullscreen=self.game_fullscreen)
Beispiel #33
0
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 = []
Beispiel #34
0
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)
Beispiel #35
0
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())
Beispiel #36
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)
Beispiel #37
0
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()
Beispiel #38
0
 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'
Beispiel #39
0
def play_game():
    
    tcod.console_init_root(settings.SCREEN_W, settings.SCREEN_H, 'SteamPocalypse')
    tcod.sys_set_fps(20)
    
    while not tcod.console_is_window_closed():

        engine.engine.handle_input()
        
        engine.engine.render_all()
Beispiel #40
0
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)
Beispiel #41
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
Beispiel #42
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())
Beispiel #43
0
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)
Beispiel #44
0
 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)
Beispiel #45
0
    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)
Beispiel #46
0
 def __init__(self, player_controls, conway_speed, map_size, fps, color,
              paddle_size, seamless):
     self.width, self.height = map_size
     self.init_players(player_controls, paddle_size)
     self.init_map(map_size, color)
     (w, h) = map_size
     tcod.console_init_root(w, h, config.GAME_TITLE, False)
     tcod.sys_set_fps(fps)
     self.conway_speed = conway_speed
     self.ball = Ball(1, 1)
     self.seamless = seamless
Beispiel #47
0
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())
Beispiel #48
0
 def init_window(self):
     T.console_init_root(self.width, self.height, self.title, False)
     self.messages = MessageLog(0, 45, 55, 5)
     self.info = InfoFrame(0, 0, 80, 1)
     self.map = MapFrame(0, 1, 55, 44)
     self.stats = StatusFrame(55, 1, 25, 79)
     self.aux = AuxFrame(0, 0, 55, 45)
     self.curtain = AuxFrame(0, 0, 80, 50)
     self.targeting = TargetingFrame(0, 1, 55, 44)
     self.prompt = PromptFrame(0, 0, 80, 1)
     self.frames = [self.info, self.messages, self.map, self.stats]
Beispiel #49
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()
Beispiel #50
0
 def init_window(self):
     T.console_init_root(self.width, self.height, self.title, False)
     self.messages = MessageLog(0, 45, 55, 5)
     self.info = InfoFrame(0, 0, 80, 1)
     self.map = MapFrame(0, 1, 55, 44)
     self.stats = StatusFrame(55, 1, 25, 79)
     self.aux = AuxFrame(0, 0, 55, 45)
     self.curtain = AuxFrame(0, 0, 80, 50)
     self.targeting = TargetingFrame(0, 1, 55, 44)
     self.prompt = PromptFrame(0, 0, 80, 1)
     self.frames = [self.info, self.messages, self.map, self.stats]
Beispiel #51
0
 def __init__(self, screenwidth, screenheight,
              title, font='terminal12x12_gs_ro.png',
              fontflags=(libtcodpy.FONT_TYPE_GREYSCALE |
                         libtcodpy.FONT_LAYOUT_ASCII_INROW),
              fullscreen=False, fps=60):
     self.screenwidth = screenwidth
     self.screenheight = screenheight
     self.set_font(font, fontflags)
     self.set_fps(fps)
     libtcodpy.console_init_root(screenwidth, screenheight,
                                 title, fullscreen)
Beispiel #52
0
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()
Beispiel #53
0
 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)
Beispiel #54
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)
Beispiel #55
0
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()
Beispiel #56
0
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)
Beispiel #57
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
Beispiel #58
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(screen_width // 2, screen_height // 2, '@', libtcod.white)
    npc = Entity(screen_width // 2 - 5, screen_height // 2, '@', libtcod.red)
    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 revisited", 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')
        playerquit = 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 playerquit:
            return True

        if fullscreen:
            libtcod.console_set_fullscreen(not libtcod.console_is_fullscreen())