Exemple #1
0
 def setup(self):
   libtcod.console_set_custom_font('assets/dejavu16x16_gs_tc.png', libtcod.FONT_TYPE_GREYSCALE | libtcod.FONT_LAYOUT_TCOD)
   libtcod.console_init_root(self.width, self.height, 'Pyrl', False)
   self.__con = libtcod.console_new(self.width, self.height)
   self.__map = Map(self.width, self.height, self.__con)
   self.__map.setup()
   self.__generate_entities()
Exemple #2
0
 def setUp(self, screenWidth, screenHeight, FPS, fgcol):
     libtcod.console_set_custom_font(self.fontImageFileName,
             libtcod.FONT_TYPE_GREYSCALE | libtcod.FONT_LAYOUT_ASCII_INROW)
     libtcod.console_init_root(screenWidth, screenHeight, 'List-editor', False)
     libtcod.sys_set_fps(FPS)
     libtcod.console_set_background_flag(0, libtcod.BKGND_SET)
     libtcod.console_set_default_foreground(0, fgcol)
Exemple #3
0
def init_libtcod():
    startup_msg = ("analyzing air quality...", "calculating primordial soup..."
        ,"reading the future...", "carbon dating your hard drive..."
        ,"finding prime numbers...")
    print(random.choice(startup_msg))
    libtcod.console_set_custom_font('data/fonts/terminal12x12_gs_ro.png', 
                                    libtcod.FONT_TYPE_GREYSCALE |
                                    libtcod.FONT_LAYOUT_ASCII_INROW)
    libtcod.console_init_root(C.SCREEN_WIDTH, C.SCREEN_HEIGHT, 
                              'top dog -- v%s' % (C.VERSION), C.FULLSCREEN)
    libtcod.sys_set_fps(C.LIMIT_FPS)
    # default font color
    libtcod.console_set_default_foreground(0, libtcod.white)
    # set color control codes for inline string formatting
    # listed by priority: think defcon levels
    # high alert, priority one
    libtcod.console_set_color_control(libtcod.COLCTRL_1
                                        ,libtcod.light_red
                                        ,libtcod.black)
    # warning, danger will robinson
    libtcod.console_set_color_control(libtcod.COLCTRL_2
                                        ,libtcod.light_yellow
                                        ,libtcod.black)
    # informational, you got a quest item
    libtcod.console_set_color_control(libtcod.COLCTRL_3
                                        ,libtcod.light_green
                                        ,libtcod.black)
    # tile and npc names
    libtcod.console_set_color_control(C.COL4
                                        ,libtcod.light_azure
                                        ,libtcod.black)
    # all other words
    libtcod.console_set_color_control(libtcod.COLCTRL_5
                                        ,libtcod.white
                                        ,libtcod.black)
    return libtcod.console_new(C.MAP_WIDTH, C.MAP_HEIGHT)
Exemple #4
0
    objects = file['objects']
    player = objects[file['player_index']]
    inventory = file['inventory']
    game_msgs = file['game_msgs']
    game_state = file['game_state']
    file.close()

    initialize_fov()


#########################################
#  3 INSTANTIATE OUR CLASSES FOR GAME   #
#                                       #
#########################################

libtcod.console_set_custom_font(
    'terminal10x10_gs_tc.png',
    libtcod.FONT_TYPE_GREYSCALE | libtcod.FONT_LAYOUT_TCOD)
libtcod.console_init_root(SCREEN_WIDTH, SCREEN_HEIGHT,
                          'roguelike demo with libtcod', False)
con = libtcod.console_new(
    SCREEN_WIDTH, SCREEN_HEIGHT
)  #this has created an offscreen console we'll use instead of printing to the main console
libtcod.sys_set_fps(LIMIT_FPS)
panel = libtcod.console_new(SCREEN_WIDTH, PANEL_HEIGHT)

#########################################
#  4 MAIN LOOP                           #
#                                       #
#########################################
main_menu()
Exemple #5
0
            libtcod.map_set_properties(fov_map, x, y, not map[x][y].blocked, not map[x][y].block_sight)

    fov_recompute = True
    ambient_recompute = True
    game_state = 'playing'
    player_action = None

    frame_counter = 0
    next_random_frame = random_frame()

init_start()
init_mechanics()
init_ambience()

#libtcod.console_set_custom_font('arial10x10.png', libtcod.FONT_TYPE_GREYSCALE | libtcod.FONT_LAYOUT_TCOD)
libtcod.console_init_root(SCREEN_WIDTH, SCREEN_HEIGHT, 'python/libtcod tutorial', False)
libtcod.sys_set_fps(LIMIT_FPS)
con = libtcod.console_new(MAP_WIDTH, MAP_HEIGHT)
panel = libtcod.console_new(SCREEN_WIDTH, PANEL_HEIGHT)

#a warm welcoming message!
message('Welcome stranger! Prepare to perish in the Tombs of the Ancient Kings.', libtcod.red)
sound_general_start.play()

while not libtcod.console_is_window_closed():

    #render the screen
    render_graphics()

    #recompute ambient sound voumes
    render_ambience()
Exemple #6
0
	#open previously saved shelve
	global map, objects, player, inventory, game_msgs, game_state

	file = shelve.open('savegame', 'r')
	map = file['map']
	objects = file['objects']
	player = objects[file['player_index']]
	inventory = file['inventory']
	game_msgs = file['game_msgs']
	game_state = file['game_state']
	file.close()

	initialize_fov()

#########################################
#  3 INSTANTIATE OUR CLASSES FOR GAME   #
#                                       #
#########################################

libtcod.console_set_custom_font('terminal10x10_gs_tc.png', libtcod.FONT_TYPE_GREYSCALE | libtcod.FONT_LAYOUT_TCOD)
libtcod.console_init_root(SCREEN_WIDTH, SCREEN_HEIGHT, 'roguelike demo with libtcod', False)
con = libtcod.console_new(SCREEN_WIDTH, SCREEN_HEIGHT) #this has created an offscreen console we'll use instead of printing to the main console
libtcod.sys_set_fps(LIMIT_FPS)
panel = libtcod.console_new(SCREEN_WIDTH, PANEL_HEIGHT)


#########################################
#  4 MAIN LOOP                           #
#                                       #
#########################################
main_menu()
    libtcod.line(rect.x1, rect.y1, rect.x1, rect.y2, listener)
    libtcod.line(rect.x2, rect.y1, rect.x2, rect.y2, listener)
    libtcod.line(rect.x1, rect.y2, rect.x2, rect.y2, listener)

    if tree.left is not None:
        trace_sections(tree.left)
    if tree.right is not None:
        trace_sections(tree.right)

trace_sections(tree)

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-one', False, libtcod.RENDERER_GLSL)

for x in range(SCREEN_WIDTH):
    for y in range(SCREEN_HEIGHT):
        col = libtcod.Color(60 * map[x][y], 60 * map[x][y], 60 * map[x][y])
        libtcod.console_set_char_background(0, x, y, col)
        libtcod.console_set_default_foreground(0, libtcod.dark_grey)
        libtcod.console_put_char(0, x, y, ".")

libtcod.console_flush()

libtcod.console_wait_for_keypress(True)

exit()
Exemple #8
0
        elif key.c == ord('r'):
            biz = random.choice(district.businesses)
            biz.visit(player)
        elif key.vk >= libtcod.KEY_0 and key.vk <= libtcod.KEY_KP9:
            # If amulet is displayed, redirect numeric input to amulet
            amulet.keyboard_input(key.vk)


#############################################
# Initialization & Main Loop
#############################################

libtcod.console_set_custom_font(
    'res/dejavu16x16_gs_tc.png',
    libtcod.FONT_TYPE_GREYSCALE | libtcod.FONT_LAYOUT_TCOD)
libtcod.console_init_root(SCREEN_WIDTH, SCREEN_HEIGHT, 'Amulet of Yelpdor',
                          False)
libtcod.sys_set_fps(LIMIT_FPS)
console = libtcod.console_new(SCREEN_WIDTH, SCREEN_HEIGHT)

district = District()
dungeon_map = generate_city_map(MAP_WIDTH, MAP_HEIGHT, district)
dungeon_map.init_fov_map()
screen = Screen(width=SCREEN_WIDTH, height=SCREEN_HEIGHT)
camera = Camera(CAMERA_WIDTH, CAMERA_HEIGHT, dungeon_map)
renderer = Renderer(console, screen, camera)
messenger = Messenger(width=MESSENGER_WIDTH,
                      height=MESSENGER_HEIGHT,
                      screen=screen)

player = Player(dungeon_map.spawn[0], dungeon_map.spawn[1], '@', libtcod.white)
dungeon_map.objects.append(player)
Exemple #9
0
    fov_recompute = True
    ambient_recompute = True
    game_state = 'playing'
    player_action = None

    frame_counter = 0
    next_random_frame = random_frame()


init_start()
init_mechanics()
init_ambience()

#libtcod.console_set_custom_font('arial10x10.png', libtcod.FONT_TYPE_GREYSCALE | libtcod.FONT_LAYOUT_TCOD)
libtcod.console_init_root(SCREEN_WIDTH, SCREEN_HEIGHT,
                          'python/libtcod tutorial', False)
libtcod.sys_set_fps(LIMIT_FPS)
con = libtcod.console_new(MAP_WIDTH, MAP_HEIGHT)
panel = libtcod.console_new(SCREEN_WIDTH, PANEL_HEIGHT)

#a warm welcoming message!
message(
    'Welcome stranger! Prepare to perish in the Tombs of the Ancient Kings.',
    libtcod.red)
sound_general_start.play()

while not libtcod.console_is_window_closed():

    #render the screen
    render_graphics()