Example #1
0
    def create_tile(self, id):

        a = Tile(self.tile_data[id][3], self.tile_data[id][4],
                 self.tile_data[id][2], libtcod.Color(*self.tile_data[id][5]),
                 libtcod.Color(*self.tile_data[id][6]))
        a.id = id
        return a
Example #2
0
    def _printStats(self, console):

        c = self.coords[self._selectedX][self._selectedY]

        messages = [(1, str(tcod.sys_get_fps()) + " FPS"),
                    (2, "Coord: (" + str(self._selectedX) + "," +
                     str(self._selectedY) + ")"),
                    (3, "X-Offset: " + str(self._offsetX)),
                    (4, "Y-Offset: " + str(self._offsetY)),
                    (5, "Altitude: " + str(c.altitude)),
                    (6, "Temp    : " + str(c.temp)),
                    (7, "Rain    : " + str(c.rainfall)),
                    (8, "Salinity: " + str(c.salinity)),
                    (9, "Spring  : " + str(c.hasSpring)),
                    (10, "Water   : " + str(c.depth)),
                    (11, "Source  : " + str(c.source)),
                    (12, "Biome   : " + str(c.biome.name))]

        tcod.console_set_foreground_color(console, tcod.Color(255, 0, 127))
        tcod.console_set_background_color(console, tcod.Color(0, 0, 0))
        for y, msg in messages:
            tcod.console_print_right(console, self._displayWidth - 1, y,
                                     tcod.BKGND_NONE, msg)
        tcod.console_set_foreground_color(console, tcod.Color(255, 255, 255))


###/////////////////////////////////////////////////////////////////////////////////////////////////
### EOF
Example #3
0
    def __init__(self,
                 x,
                 y,
                 blocked,
                 block_sight=None,
                 char=" ",
                 cost=10,
                 bg=[60, 100, 80],
                 fg=[255, 255, 255],
                 map_tile=False):
        self.blocked = blocked
        self.x = x
        self.y = y
        self.colours = [bg[0], bg[1], bg[2], fg[0], fg[1], fg[2]]
        if bg[0] >= 255:
            bg[0] = 254
        if bg[1] >= 255:
            bg[1] = 254
        if bg[2] >= 255:
            bg[2] = 254
        self.bg = libtcod.Color(bg[0], bg[1], bg[2])
        self.fg = libtcod.Color(fg[0], fg[1], fg[2])
        self.explored = False  #all tiles start unexplored
        self.char = char
        self.cost = cost  #10 for normal tile, 5 for road?

        if block_sight is None:
            block_sight = blocked  #by default, if a tile is blocked, it also blocks sight
        else:
            self.block_sight = block_sight
        if map_tile is True:
            self.mapTile()

        self.type = ""
Example #4
0
 def create_h_tunnel(self, x1, x2, y):
     for x in range(min(x1, x2), max(x1, x2) + 1):
         self.tiles[x][y] = Tile(False,
                                 "Floor",
                                 libtcod.Color(200, 180, 50),
                                 libtcod.Color(50, 50, 150),
                                 char='.')
Example #5
0
    def on_tick(self, object=None):
        if self.temperature > 8:
            self.owner.color = libtcod.Color(255, 244, 247)
        elif self.temperature > 6:
            self.owner.color = libtcod.Color(255, 219, 20)
        elif self.temperature > 4:
            self.owner.color = libtcod.Color(250, 145, 20)
        elif self.temperature > 2:
            self.owner.color = libtcod.Color(232, 35, 0)
        else:
            self.owner.color = libtcod.Color(100, 100, 100)

        self.temperature -= 1
        if self.temperature == 0:
            self.owner.destroy()
        else:
            for obj in game.get_objects(self.owner.x, self.owner.y,
                                        lambda o: o.fighter is not None):
                obj.fighter.apply_status_effect(effects.burning(), dc=None)
            # Spread to adjacent tiles
            if self.temperature < 9:  # don't spread on the first turn
                for tile in game.adjacent_tiles_diagonal(
                        self.owner.x, self.owner.y):
                    if libtcod.random_get_int(
                            0, 1, 100) <= game.current_map.tiles[tile[0]][
                                tile[1]].flammable:
                        game.create_fire(tile[0], tile[1], 10)
                    if game.current_map.tiles[tile[0]][tile[1]].is_ice:
                        game.melt_ice(tile[0], tile[1])
Example #6
0
 def __init__(self, width, height):
     self.width = width
     self.height = height
     self.tiles = [[
         Tile(0, libtcod.Color(0, 0, 0), libtcod.Color(0, 0, 0), 0)
         for y in range(self.height)
     ] for x in range(self.width)]
Example #7
0
def get_constants():
    window_title = "Roguelike"

    # window/player view parameters
    screen_width = 80
    screen_height = 50

    fov_algorithm = libtcod.FOV_SHADOW
    fov_light_walls = True
    fov_radius = 10
    fov_recompute = True

    # UI panel parameters
    ui_panel_width = 20
    ui_panel_height = 7
    ui_panel_y = screen_height - ui_panel_height

    # Message log parameters
    message_panel_x = ui_panel_width + 2
    message_panel_width = screen_width - ui_panel_width - 2
    message_panel_height = ui_panel_height - 1

    # World parameters
    map_width = 80
    map_height = 43

    room_max_size = 15
    room_min_size = 10
    max_rooms = 30

    colors = {
        'dark_wall': libtcod.Color(0, 0, 100),
        'dark_ground': libtcod.Color(50, 50, 150),
        'light_wall': libtcod.Color(130, 110, 50),
        'light_ground': libtcod.Color(200, 180, 50)
    }

    constants = {
        "window_title": window_title,
        "screen_width": screen_width,
        "screen_height": screen_height,
        "fov_algorithm": fov_algorithm,
        "fov_light_walls": fov_light_walls,
        "fov_radius": fov_radius,
        "fov_recompute": fov_recompute,
        "ui_panel_width": ui_panel_width,
        "ui_panel_height": ui_panel_height,
        "ui_panel_y": ui_panel_y,
        "message_panel_x": message_panel_x,
        "message_panel_width": message_panel_width,
        "message_panel_height": message_panel_height,
        "map_width": map_width,
        "map_height": map_height,
        "room_max_size": room_max_size,
        "room_min_size": room_min_size,
        "max_rooms": max_rooms,
        "colors": colors
    }

    return constants
Example #8
0
def get_constants():
    window_title = 'Roguelike Tutorial Revised'

    screen_width = 80
    screen_height = 50

    bar_width = 20
    panel_height = 7
    panel_y = screen_height - panel_height

    message_x = bar_width + 2
    message_width = screen_width - bar_width - 2
    message_height = panel_height - 1

    map_width = 80
    map_height = 43

    room_max_size = 10
    room_min_size = 6
    max_rooms = 30

    fov_algorithm = 0
    fov_light_walls = True
    fov_radius = 10

    max_monsters_per_room = 3
    max_items_per_room = 2

    colors = {
        'player': libtcod.white,
        'dark_wall': libtcod.Color(0, 0, 100),
        'dark_ground': libtcod.Color(50, 50, 150),
        'light_wall': libtcod.Color(130, 110, 50),
        'light_ground': libtcod.Color(200, 180, 50)
    }

    constants = {
        'window_title': window_title,
        'screen_width': screen_width,
        'screen_height': screen_height,
        'bar_width': bar_width,
        'panel_height': panel_height,
        'panel_y': panel_y,
        'message_x': message_x,
        'message_width': message_width,
        'message_height': message_height,
        'map_width': map_width,
        'map_height': map_height,
        'room_max_size': room_max_size,
        'room_min_size': room_min_size,
        'max_rooms': max_rooms,
        'fov_algorithm': fov_algorithm,
        'fov_light_walls': fov_light_walls,
        'fov_radius': fov_radius,
        'max_monsters_per_room': max_monsters_per_room,
        'max_items_per_room': max_items_per_room,
        'colors': colors
    }

    return constants
Example #9
0
def test_image(console, tmpdir):
    img = libtcodpy.image_new(16, 16)
    libtcodpy.image_clear(img, libtcodpy.Color(0, 0, 0))
    libtcodpy.image_invert(img)
    libtcodpy.image_hflip(img)
    libtcodpy.image_rotate90(img)
    libtcodpy.image_vflip(img)
    libtcodpy.image_scale(img, 24, 24)
    libtcodpy.image_set_key_color(img, libtcodpy.Color(255, 255, 255))
    libtcodpy.image_get_alpha(img, 0, 0)
    libtcodpy.image_is_pixel_transparent(img, 0, 0)
    libtcodpy.image_get_size(img)
    libtcodpy.image_get_pixel(img, 0, 0)
    libtcodpy.image_get_mipmap_pixel(img, 0, 0, 1, 1)
    libtcodpy.image_put_pixel(img, 0, 0, libtcodpy.Color(255, 255, 255))
    libtcodpy.image_blit(img, console, 0, 0, libtcodpy.BKGND_SET, 1, 1, 0)
    libtcodpy.image_blit_rect(img, console, 0, 0, 16, 16, libtcodpy.BKGND_SET)
    libtcodpy.image_blit_2x(img, console, 0, 0)
    libtcodpy.image_save(img, tmpdir.join('test.png').strpath)
    libtcodpy.image_delete(img)

    # Not portable.
    #img = libtcodpy.image_from_console(console)
    #libtcodpy.image_refresh_console(img, console)
    #libtcodpy.image_delete(img)

    libtcodpy.image_delete(libtcodpy.image_load('../data/img/circle.png'))
Example #10
0
    def create(self):
        w = cfg.DNG_MINWIDTH + random.randint(0, cfg.DNG_SIZEVAR)
        h = cfg.DNG_MINHEIGHT + random.randint(0, cfg.DNG_SIZEVAR)
        self.width = w
        self.height = h

        self.level = [[DungeonTile(j, i) for i in xrange(h)]
                      for j in xrange(w)]
        self.console = libtcod.console_new(w, h)

        backColor = libtcod.Color(0, 0, 0)

        # magic!
        bsp_depth = 9
        bsp_min_room_size = 5

        bsp = libtcod.bsp_new_with_size(0, 0, w, h)
        libtcod.bsp_split_recursive(bsp, 0, bsp_depth, bsp_min_room_size,
                                    bsp_min_room_size, 1.5, 1.5)
        libtcod.bsp_traverse_inverted_level_order(bsp, self.traverseNode)

        self.findPathable()
        self.clearUnpathableAreas()

        # Place entrance

        e_pos = random.choice(self.pathable)
        entry = DungeonTileEntity(e_pos[0], e_pos[1])
        entry.setChar('>')
        entry.setColors(libtcod.Color(0, 100, 150), libtcod.Color(40, 40, 0))
        self.tile_entity.append(entry)
        self.entry = entry

        self.buildBlockedMap()
Example #11
0
 def refresh_gui_background(self, gui):
     libtcod.console_clear(gui)
     for x in xrange(self.SCREEN_WIDTH):
         for y in xrange(self.SCREEN_HEIGHT):
             libtcod.console_set_char_background(
                 gui, x, y, libtcod.Color(100, 100, 100))
     if self.paused == True:
         pause_text = "***PAUSED***"
         for x in xrange(12):
             libtcod.console_set_char_background(
                 gui, self.CAMERA_WIDTH - 15 + x, 0,
                 libtcod.Color(100, 100, 200))
             libtcod.console_put_char(gui, self.CAMERA_WIDTH - 15 + x, 0,
                                      pause_text[x], libtcod.BKGND_NONE)
             libtcod.console_set_char_foreground(
                 gui, self.CAMERA_WIDTH - 15 + x, 0,
                 libtcod.Color(255, 255, 255))
     if self.loading > -1:
         loading_text = "***LOADING***"
         for x in xrange(13):
             libtcod.console_set_char_background(
                 gui, 15 + x, 0, libtcod.Color(100, 100, 200))
             libtcod.console_put_char(gui, 15 + x, 0, loading_text[x],
                                      libtcod.BKGND_NONE)
             libtcod.console_set_char_foreground(
                 gui, 15 + x, 0, libtcod.Color(255, 255, 255))
Example #12
0
 def create_v_tunnel(self, y1, y2, x):
     for y in range(min(y1, y2), max(y1, y2) + 1):
         self.tiles[x][y] = Tile(False,
                                 "Floor",
                                 libtcod.Color(200, 180, 50),
                                 libtcod.Color(50, 50, 150),
                                 char='.')
Example #13
0
    def __init__(self, root_console_width, root_console_height, frame_manager):
        self.entity_manager = frame_manager.parent_menu.entity_manager

        # load xp for bg
        console_bg_xp = gzip.open('assets\\ui\\ui_frame_libraries_bg.xp')
        self.bg_data = xp_loader.load_xp_string(console_bg_xp.read())

        Frame.__init__(self, root_console_width, root_console_height,
                       self.bg_data['width'], self.bg_data['height'],
                       frame_manager)

        library_start_xy = xp_loader.get_position_key_xy(
            self.bg_data['layer_data'][1], xp_loader.poskey_color_red)

        self.library_start_xy = Vec2d(library_start_xy[0], library_start_xy[1])
        self.library_line_extent = xp_loader.get_position_key_xy(
            self.bg_data['layer_data'][1], xp_loader.poskey_color_green)

        #TODO put these in config somewhere
        self.line_char = chr(196)
        self.line_bg = libtcod.Color(2, 22, 12)
        self.line_fg = libtcod.Color(6, 130, 60)
        self.libname_fg = libtcod.Color(102, 255, 178)

        libtcod.console_set_default_background(self.console, self.line_bg)
        libtcod.console_set_default_foreground(self.console, self.libname_fg)
        libtcod.console_set_alignment(self.console, libtcod.LEFT)

        xp_loader.load_layer_to_console(self.console,
                                        self.bg_data['layer_data'][0])
Example #14
0
    def __init__(self, con, width, height, max_room_size, min_room_size, max_rooms,
            torch_radius, light_walls, algorithm):
        """Initialize the map to a width and height

        :width: width of the map
        :height: height of the map

        """
        self.dark_wall = tcod.Color(0, 0, 100)
        self.light_wall = tcod.Color(130, 110, 50)
        self.dark_ground = tcod.Color(50, 50, 150)
        self.light_ground = tcod.Color(200, 180, 50)

        self._torch_radius = torch_radius
        self._light_walls = light_walls
        self._algorithm = algorithm
        
        self._max_room_size = max_room_size
        self._min_room_size = min_room_size
        self._max_rooms = max_rooms

        self._width = width
        self._height = height
        self._map = [ [Tile(True) 
            for y in range(self._height) ]
                for x in range(self._width) ]

        self._fov_map = tcod.map_new(width, height)

        self._con = con
Example #15
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 = []
Example #16
0
    def convert_crude(self, smap, debug=False):
        fov_dark_wall = libtcod.Color(0, 0, 100)
        fov_light_wall = libtcod.Color(130, 110, 50)
        fov_dark_ground = libtcod.Color(50, 50, 150)
        fov_light_ground = libtcod.Color(200, 180, 50)

        map_data = []
        for y in range(len(smap)):
            collector = []
            for x in range(len(smap[y])):
                walkable = False
                visible = False
                text = ' '
                color_dark = fov_dark_wall
                color_light = fov_light_wall
                onStep = False
                if smap[y][x] == ' ':
                    walkable = True
                    visible = True
                    color_dark = fov_dark_ground
                    color_light = fov_light_ground
                elif smap[y][x] == 'B':
                    walkable = True
                    visible = False
                    color_dark = fov_dark_ground
                    color_light = fov_light_ground
                    text = 'B'
                elif smap[y][x] == '=':
                    visible = True
                    color_dark = fov_dark_ground
                    color_light = fov_light_ground
                    text = libtcod.CHAR_DHLINE
                    self.objects["door1"] = (x, y)
                elif smap[y][x] == 'i':
                    visible = True
                    walkable = True
                    color_dark = fov_dark_ground
                    color_light = fov_light_ground
                    text = 'i'
                    onStep = slip
                elif smap[y][x] == 't':
                    visible = True
                    walkable = True
                    color_dark = fov_dark_ground
                    color_light = fov_light_ground
                    text = 't'
                    onStep = trigger
                elif smap[y][x] == 's':
                    visible = True
                    walkable = True
                    color_dark = fov_dark_ground
                    color_light = fov_light_ground
                    text = 't'
                    onStep = gennewmap
                currentTile = Tile.Tile(walkable, visible, text, color_light,
                                        color_dark, onStep, debug)
                collector.append(currentTile)
            map_data.append(collector)
            self.load_map(map_data)
def get_constants():
    window_title = 'Im a sneaky gay tee hee c:'

    screen_width = 90
    screen_height = 50

    #this is an hp bar
    bar_width = 20
    panel_height = 7
    panel_y = screen_height - panel_height
    #the message bar
    message_x = bar_width + 2
    message_width = screen_width - bar_width - 2
    message_height = panel_height - 1
    #map size
    map_width = 90
    map_height = 43
    #room variables
    room_max_size = 15
    room_min_size = 6
    max_rooms = 30
    #fov algorithm variables
    fov_algorithm = 3 # the kind of algorithm libtcod uses
    fov_light_walls = True
    fov_radius = 10
    #entity variables
    max_monsters_per_room = 3
    max_items_per_room = 2
    #misc aesthetic stuff
    colours = {                                                                     #decorative bits
        'dark_wall': libtcod.Color(0,0,100),
        'dark_ground': libtcod.Color(50,50,150),
        'light_wall': libtcod.Color(130, 110, 50),
        'light_ground': libtcod.Color(200, 180, 50)
        }
    constants = {
        'window_title': window_title,
        'screen_width': screen_width,
        'screen_height': screen_height,
        'bar_width': bar_width,
        'panel_height': panel_height,
        'panel_y': panel_y,
        'message_x': message_x,
        'message_width': message_width,
        'message_height': message_height,
        'map_width': map_width,
        'map_height': map_height,
        'room_max_size': room_max_size,
        'room_min_size': room_min_size,
        'max_rooms': max_rooms,
        'fov_algorithm': fov_algorithm,
        'fov_light_walls': fov_light_walls,
        'fov_radius': fov_radius,
        'max_monsters_per_room': max_monsters_per_room,
        'max_items_per_room': max_items_per_room,
        'colours': colours
        }

    return constants
Example #18
0
def get_constants():
    window_title = 'Save The Prince'

    screen_width = 80
    screen_height = 60

    bar_width = 20
    panel_height = 7
    panel_y = screen_height - panel_height

    message_x = bar_width + 2
    message_width = screen_width - bar_width - 2
    message_height = panel_height - 1

    map_width = 80
    map_height = 43

    room_max_size = 20
    room_min_size = 6
    max_rooms = 35

    fov_algorithm = 0
    fov_light_walls = True
    fov_radius = 5

    max_monsters_per_room = 3
    max_items_per_room = 4

    colors = {
        'dark_wall': libtcod.Color(0, 0, 100),
        'dark_ground': libtcod.Color(50, 50, 150),
        'light_wall': libtcod.Color(250, 10, 50),
        'light_ground': libtcod.Color(200, 180, 50)
    }

    constants = {
        'window_title': window_title,
        'screen_width': screen_width,
        'screen_height': screen_height,
        'bar_width': bar_width,
        'panel_height': panel_height,
        'panel_y': panel_y,
        'message_x': message_x,
        'message_width': message_width,
        'message_height': message_height,
        'map_width': map_width,
        'map_height': map_height,
        'room_max_size': room_max_size,
        'room_min_size': room_min_size,
        'max_rooms': max_rooms,
        'fov_algorithm': fov_algorithm,
        'fov_light_walls': fov_light_walls,
        'fov_radius': fov_radius,
        'max_monsters_per_room': max_monsters_per_room,
        'max_items_per_room': max_items_per_room,
        'colors': colors
    }

    return constants
def get_constants():
    window_title = 'agagagag kill kobolds agagagag'

    screen_width = 80
    screen_height = 50

    bar_width = 20
    panel_height = 7
    panel_y = screen_height - panel_height

    message_x = bar_width + 2
    message_width = screen_width - bar_width - 2
    message_height = panel_height - 1

    map_width = 80
    map_height = 43

    room_max_size = 10
    room_min_size = 6
    max_rooms = 30

    fov_algorithm = 0
    fov_light_walls = True
    fov_radius = 10

    max_monsters_per_room = 3
    max_items_per_room = 2

    colors = {
        'dark_wall': libtcod.Color(80, 80, 80),
        'dark_ground': libtcod.Color(40, 40, 40),
        'light_wall': libtcod.Color(200, 200, 200),
        'light_ground': libtcod.Color(100, 100, 100)
    }

    constants = {
        'window_title': window_title,
        'screen_width': screen_width,
        'screen_height': screen_height,
        'bar_width': bar_width,
        'panel_height': panel_height,
        'panel_y': panel_y,
        'message_x': message_x,
        'message_width': message_width,
        'message_height': message_height,
        'map_width': map_width,
        'map_height': map_height,
        'room_max_size': room_max_size,
        'room_min_size': room_min_size,
        'max_rooms': max_rooms,
        'fov_algorithm': fov_algorithm,
        'fov_light_walls': fov_light_walls,
        'fov_radius': fov_radius,
        'max_monsters_per_room': max_monsters_per_room,
        'max_items_per_room': max_items_per_room,
        'colors': colors
    }

    return constants
Example #20
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())
def get_constants():
    window_title = "SOMEWHAT ROGUELIKE"

    screen_width = 80
    screen_height = 50

    bar_width = 20
    panel_height = 7
    panel_y = screen_height - panel_height

    message_x = bar_width + 2
    message_width = screen_width - bar_width - 2
    message_height = panel_height - 1

    map_width = 80
    map_height = 43

    room_max_size = 10
    room_min_size = 6
    max_rooms = 30

    fov_algorithm = 0
    fov_light_walls = True
    fov_radius = 10

    max_monsters_per_room = 3
    max_items_per_room = 2

    colors = {
        "dark_wall": libtcod.Color(50, 50, 50),
        "dark_ground": libtcod.Color(100, 100, 100),
        "light_wall": libtcod.Color(130, 130, 130),
        "light_ground": libtcod.Color(200, 200, 200)
    }

    constants = {
        "window_title": window_title,
        "screen_width": screen_width,
        "screen_height": screen_height,
        "bar_width": bar_width,
        "panel_height": panel_height,
        "panel_y": panel_y,
        "message_x": message_x,
        "message_width": message_width,
        "message_height": message_height,
        "map_width": map_width,
        "map_height": map_height,
        "room_max_size": room_max_size,
        "room_min_size": room_min_size,
        "max_rooms": max_rooms,
        "fov_algorithm": fov_algorithm,
        "fov_light_walls": fov_light_walls,
        "fov_radius": fov_radius,
        "max_monsters_per_room": max_monsters_per_room,
        "max_items_per_room": max_items_per_room,
        "colors": colors
    }

    return constants
Example #22
0
def get_constants():
    window_title = 'WARSCIIOR'

    screen_width = 100
    screen_height = 60

    bar_width = 20
    panel_height = 17
    panel_y = screen_height - panel_height

    message_x = bar_width + 2
    message_width = screen_width - bar_width - 2
    message_height = panel_height - 1

    map_width = 100
    map_height = 43

    room_max_size = 15
    room_min_size = 6
    max_rooms = 45

    fov_algorithm = 0
    fov_light_walls = True
    fov_radius = 10

    max_monsters_per_room = 2
    max_items_per_room = 2

    colors = {
        'dark_wall': libtcod.Color(105, 105, 105),
        'dark_ground': libtcod.Color(128, 128, 128),
        'light_wall': libtcod.Color(130, 110, 50),
        'light_ground': libtcod.Color(200, 180, 50)
    }

    constants = {
        'window_title': window_title,
        'screen_width': screen_width,
        'screen_height': screen_height,
        'bar_width': bar_width,
        'panel_height': panel_height,
        'panel_y': panel_y,
        'message_x': message_x,
        'message_width': message_width,
        'message_height': message_height,
        'map_width': map_width,
        'map_height': map_height,
        'room_max_size': room_max_size,
        'room_min_size': room_min_size,
        'max_rooms': max_rooms,
        'fov_algorithm': fov_algorithm,
        'fov_light_walls': fov_light_walls,
        'fov_radius': fov_radius,
        'max_monsters_per_room': max_monsters_per_room,
        'max_items_per_room': max_items_per_room,
        'colors': colors
    }

    return constants
Example #23
0
def create_desk(x, y):
    tile = Tile()
    tile.type = TileType.DESK
    tile.block_sight = False
    tile.block_move = True
    tile.char = ' '
    tile.fcolour = libtcod.Color(120, 120, 120)
    tile.bcolour = libtcod.Color(120, 120, 120)
    return tile
Example #24
0
def create_laminate_floor(x, y):
    tile = Tile()
    tile.type = TileType.LAMINATE_FLOOR
    tile.block_sight = False
    tile.block_move = False
    tile.char = ' '
    tile.fcolour = libtcod.Color(140, 140, 190)
    tile.bcolour = libtcod.Color(140, 140, 190)
    return tile
Example #25
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())
Example #26
0
 def create_room(self, room):
     # Go through the tiles in the rectangle and make them passable
     for x in range(room.x1 + 1, room.x2):
         for y in range(room.y1 + 1, room.y2):
             self.tiles[x][y] = Tile(False,
                                     "Floor",
                                     libtcod.Color(0, 128, 0),
                                     libtcod.Color(32, 32, 125),
                                     char='.')
Example #27
0
def create_wall(x, y):
    tile = Tile()
    tile.type = TileType.WALL
    tile.block_sight = True
    tile.block_move = True
    tile.char = ' '
    tile.fcolour = libtcod.Color(96, 96, 96)
    tile.bcolour = libtcod.Color(96, 96, 96)
    return tile
Example #28
0
def create_dark_grass(x, y):
    tile = Tile()
    tile.type = TileType.GRASS
    tile.block_sight = False
    tile.block_move = False
    tile.char = ' '
    tile.fcolour = libtcod.Color(0, 108, 0)
    tile.bcolour = libtcod.Color(0, 108, 0)
    return tile
Example #29
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())
Example #30
0
def create_house(game_map, room):
    # Draw corners
    game_map.tiles[room.x1][room.y1] = Tile(True,
                                            "Wall",
                                            libtcod.dark_sepia,
                                            libtcod.Color(0, 0, 100),
                                            char=201)
    game_map.tiles[room.x2][room.y1] = Tile(True,
                                            "Wall",
                                            libtcod.dark_sepia,
                                            libtcod.Color(0, 0, 100),
                                            char=187)
    game_map.tiles[room.x1][room.y2] = Tile(True,
                                            "Wall",
                                            libtcod.dark_sepia,
                                            libtcod.Color(0, 0, 100),
                                            char=200)
    game_map.tiles[room.x2][room.y2] = Tile(True,
                                            "Wall",
                                            libtcod.dark_sepia,
                                            libtcod.Color(0, 0, 100),
                                            char=188)

    # Draw horizontal walls
    for x in range(room.x1 + 1, room.x2):
        game_map.tiles[x][room.y1] = Tile(True,
                                          "Wall",
                                          libtcod.dark_sepia,
                                          libtcod.Color(0, 0, 100),
                                          char=205)
        game_map.tiles[x][room.y2] = Tile(True,
                                          "Wall",
                                          libtcod.dark_sepia,
                                          libtcod.Color(0, 0, 100),
                                          char=205)

    # Draw vertical walls
    for y in range(room.y1 + 1, room.y2):
        game_map.tiles[room.x1][y] = Tile(True,
                                          "Wall",
                                          libtcod.dark_sepia,
                                          libtcod.Color(0, 0, 100),
                                          char=186)
        game_map.tiles[room.x2][y] = Tile(True,
                                          "Wall",
                                          libtcod.dark_sepia,
                                          libtcod.Color(0, 0, 100),
                                          char=186)

    for x in range(room.x1 + 1, room.x2):
        for y in range(room.y1 + 1, room.y2):
            game_map.tiles[x][y] = Tile(False,
                                        "Floor",
                                        libtcod.Color(130, 110, 50),
                                        libtcod.Color(0, 0, 100),
                                        char='.')