Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
elif oc_x == -5:
oc_xdir = 1
if oc_y == SAMPLE_SCREEN_HEIGHT / 2 + 5:
oc_ydir = -1
elif oc_y == -5:
oc_ydir = 1
libtcod.console_blit(oc_screenshot, 0, 0, SAMPLE_SCREEN_WIDTH,
SAMPLE_SCREEN_HEIGHT, sample_console, 0, 0)
libtcod.console_blit(oc_secondary, 0, 0, SAMPLE_SCREEN_WIDTH // 2,
SAMPLE_SCREEN_HEIGHT // 2, sample_console, oc_x, oc_y,
1.0,0.75)
#############################################
# line drawing sample
#############################################
line_bk = libtcod.Color()
line_init = False
line_bk_flag = libtcod.BKGND_SET
def render_lines(first, key, mouse):
global line_bk, line_init, line_bk_flag
flag_names=['BKGND_NONE',
'BKGND_SET',
'BKGND_MULTIPLY',
'BKGND_LIGHTEN',
'BKGND_DARKEN',
'BKGND_SCREEN',
'BKGND_COLOR_DODGE',
'BKGND_COLOR_BURN',
'BKGND_ADD',
'BKGND_ADDALPHA',
def test_color_math():
color_a = libtcodpy.Color(0, 1, 2)
color_b = libtcodpy.Color(0, 10, 20)
assert color_a + color_b == libtcodpy.Color(0, 11, 22)
assert color_b - color_a == libtcodpy.Color(0, 9, 18)
assert libtcodpy.Color(255, 255, 255) * color_a == color_a
assert color_a * 100 == libtcodpy.Color(0, 100, 200)
poskey_tile_character = 219
#some or all of the below may appear in libtcod's color definitions; and in fact, you can use libtcod colors as you please for position keys.
#These are merely the colors provided in the accompanying palette.
poskey_color_red = libtcod.Color(255, 0, 0)
poskey_color_lightpurple = libtcod.Color(254, 0, 255) # specifically 254 as 255, 0, 255 is considered a transparent key color in REXPaint
poskey_color_orange = libtcod.Color(255, 128, 0)
poskey_color_pink = libtcod.Color(255, 0, 128)
poskey_color_green = libtcod.Color(0, 255, 0)
poskey_color_teal = libtcod.Color(0, 255, 255)
poskey_color_yellow = libtcod.Color(255, 255, 0)
poskey_color_blue = libtcod.Color(0, 0, 255)
poskey_color_lightblue = libtcod.Color(0, 128, 255)
poskey_color_purple = libtcod.Color(128, 0, 255)
poskey_color_white = libtcod.Color(255, 255, 255)
##################################
# please note - this function writes the contents of transparent cells to the provided console.
# If you're building an offscreen console and want to use the default (or some other) color for transparency, please call libtcod's console.set_key_color(color)
##################################
def load_layer_to_console(console, xp_file_layer):
if not xp_file_layer['width'] or not xp_file_layer['height']:
raise AttributeError('Attempted to call load_layer_to_console on data that didn\'t have a width or height key, check your data')
for x in range(xp_file_layer['width']):
for y in range(xp_file_layer['height']):
cell_data = xp_file_layer['cells'][x][y]
fore_color = libtcod.Color(cell_data['fore_r'], cell_data['fore_g'], cell_data['fore_b'])
back_color = libtcod.Color(cell_data['back_r'], cell_data['back_g'], cell_data['back_b'])
libtcod.console_put_char_ex(console, x, y, cell_data['keycode'], fore_color, back_color)
def parser_get_color_property(parser, name):
return _tcod.Color.from_cdata(_lib.TCOD_parser_get_color_property(parser, _bytes(name)))
dark_pink = Color(191, 0, 95)
dark_crimson = Color(191, 0, 47)
# darker s
darker_red = Color(127, 0, 0)
darker_flame = Color(127, 31, 0)
darker_orange = Color(127, 63, 0)
darker_amber = Color(127, 95, 0)
darker_yellow = Color(127, 127, 0)
darker_lime = Color(95, 127, 0)
darker_chartreuse = Color(63, 127, 0)
darker_green = Color(0, 127, 0)
darker_sea = Color(0, 127, 63)
darker_turquoise = Color(0, 127, 95)
darker_cyan = Color(0, 127, 127)
darker_sky = Color(0, 95, 127)
darker_azure = Color(0, 63, 127)
darker_blue = Color(0, 0, 127)
darker_han = Color(31, 0, 127)
darker_violet = Color(63, 0, 127)
darker_purple = Color(95, 0, 127)
darker_fuchsia = Color(127, 0, 127)
darker_magenta = Color(127, 0, 95)
darker_pink = Color(127, 0, 63)
darker_crimson = Color(127, 0, 31)
# darkest s
darkest_red = Color(63, 0, 0)
darkest_flame = Color(63, 15, 0)
darkest_orange = Color(63, 31, 0)
darkest_amber = Color(63, 47, 0)
darkest_yellow = Color(63, 63, 0)
#dark_wall = Color(63, 63, 63)
dark_wall_fg = Color(95, 95, 95)
#dark_ground = Color(31, 31, 31)
dark_ground_fg = Color(95, 95, 95)
floor_default = Color(245, 245, 200)
wall_default = Color(95, 95, 95)
# Dungeon #
stone = Color(104, 113, 112)
granite = Color(148, 146, 123)
clay = Color(153, 102, 51)
# Entities
blood_red = Color(127, 0, 0)
blood_ins = Color(236,255,0)
blood_slime = Color(176,255,0)
# Materials #
oak = Color(120, 81, 45)
linen = Color(186, 183, 162)
cotton = Color(191, 186, 175)
leather = Color(181, 121, 84)
iron = Color(110, 96, 93)
steel = Color(106, 108, 112)
# UI #
panel_stat_active = Color(255, 191, 0)
panel_inactive = Color(127, 127, 127) # Dark Gray
# custom
light_orange = Color(255, 184, 114)
light_amber = Color(255, 219, 114)
light_yellow = Color(255, 255, 114)
light_lime = Color(219, 255, 114)
light_chartreuse = Color(184, 255, 114)
light_green = Color(114, 255, 114)
light_sea = Color(114, 255, 184)
light_turquoise = Color(114, 255, 219)
light_cyan = Color(114, 255, 255)
light_sky = Color(114, 219, 255)
light_azure = Color(114, 184, 255)
light_blue = Color(114, 114, 255)
light_han = Color(149, 114, 255)
light_violet = Color(184, 114, 255)
light_purple = Color(219, 114, 255)
light_fuchsia = Color(255, 114, 255)
light_magenta = Color(255, 114, 219)
light_pink = Color(255, 114, 184)
light_crimson = Color(255, 114, 149)
# lighter s
lighter_red = Color(255, 165, 165)
lighter_flame = Color(255, 188, 165)
lighter_orange = Color(255, 210, 165)
lighter_amber = Color(255, 232, 165)
lighter_yellow = Color(255, 255, 165)
lighter_lime = Color(232, 255, 165)
lighter_chartreuse = Color(210, 255, 165)
lighter_green = Color(165, 255, 165)
lighter_sea = Color(165, 255, 210)
lighter_turquoise = Color(165, 255, 232)
lighter_cyan = Color(165, 255, 255)
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": tcod.Color(0, 0, 100),
"dark_ground": tcod.Color(50, 50, 150),
"light_wall": tcod.Color(130, 110, 50),
"light_ground": tcod.Color(200, 180, 50),
}
constants = {
"window_title": window_title,
"screen_width": screen_width,
"screen_height": screen_height,
"full_screen": full_screen,
"renderer": renderer,
"bar_width": bar_width,
"panel_height": panel_height,
"panel_y": panel_y,
"message_x": message_x,
"message_width": message_width,
darkest_pink = Color(63, 0, 31)
darkest_crimson = Color(63, 0, 15)
# light s
light_red = Color(255, 114, 114)
light_flame = Color(255, 149, 114)
light_orange = Color(255, 184, 114)
light_amber = Color(255, 219, 114)
light_yellow = Color(255, 255, 114)
light_lime = Color(219, 255, 114)
light_chartreuse = Color(184, 255, 114)
light_green = Color(114, 255, 114)
light_sea = Color(114, 255, 184)
light_turquoise = Color(114, 255, 219)
light_cyan = Color(114, 255, 255)
light_sky = Color(114, 219, 255)
light_azure = Color(114, 184, 255)
light_blue = Color(114, 114, 255)
light_han = Color(149, 114, 255)
light_violet = Color(184, 114, 255)
light_purple = Color(219, 114, 255)
light_fuchsia = Color(255, 114, 255)
light_magenta = Color(255, 114, 219)
light_pink = Color(255, 114, 184)
light_crimson = Color(255, 114, 149)
# lighter s
lighter_red = Color(255, 165, 165)
lighter_flame = Color(255, 188, 165)
lighter_orange = Color(255, 210, 165)
lighter_amber = Color(255, 232, 165)
lighter_yellow = Color(255, 255, 165)
# lighter s
lighter_red = Color(255, 165, 165)
lighter_flame = Color(255, 188, 165)
lighter_orange = Color(255, 210, 165)
lighter_amber = Color(255, 232, 165)
lighter_yellow = Color(255, 255, 165)
lighter_lime = Color(232, 255, 165)
lighter_chartreuse = Color(210, 255, 165)
lighter_green = Color(165, 255, 165)
lighter_sea = Color(165, 255, 210)
lighter_turquoise = Color(165, 255, 232)
lighter_cyan = Color(165, 255, 255)
lighter_sky = Color(165, 232, 255)
lighter_azure = Color(165, 210, 255)
lighter_blue = Color(165, 165, 255)
lighter_han = Color(188, 165, 255)
lighter_violet = Color(210, 165, 255)
lighter_purple = Color(232, 165, 255)
lighter_fuchsia = Color(255, 165, 255)
lighter_magenta = Color(255, 165, 232)
lighter_pink = Color(255, 165, 210)
lighter_crimson = Color(255, 165, 188)
# lightest s
lightest_red = Color(255, 191, 191)
lightest_flame = Color(255, 207, 191)
lightest_orange = Color(255, 223, 191)
lightest_amber = Color(255, 239, 191)
lightest_yellow = Color(255, 255, 191)
lightest_lime = Color(239, 255, 191)
lightest_chartreuse = Color(223, 255, 191)
lightest_green = Color(191, 255, 191)