Esempio n. 1
0
def update():
    global DRAW_CALLS

    for call in DRAW_CALLS[:constants.MAX_DRAW_CALLS_PER_FRAME]:
        _draw_list = list(call)

        if not _draw_list:
            continue

        for draw in _draw_list:
            surface_name, x, y, c, fore_color, back_color = draw

            _set_char(surface_name,
                      x,
                      y,
                      c,
                      fore_color=fore_color,
                      back_color=back_color)

    DRAW_CALLS = DRAW_CALLS[constants.MAX_DRAW_CALLS_PER_FRAME:]

    tcod.console_set_default_background(0, tcod.dark_gray)
    tcod.console_fill_char(0, SCREEN['c'])
    tcod.console_fill_background(0, SCREEN['b'][0], SCREEN['b'][1],
                                 SCREEN['b'][2])
    tcod.console_fill_foreground(0, SCREEN['f'][0], SCREEN['f'][1],
                                 SCREEN['f'][2])

    _clear_screen()
    cleanup()
Esempio n. 2
0
def _draw_view(view):
    if view['light_buffer']:
        tcod.console_fill_foreground(
            view['console'],
            numpy.subtract(
                numpy.add(
                    numpy.subtract(view['col_buffer'][0][0],
                                   RGB_LIGHT_BUFFER[0]),
                    view['light_buffer'][0]),
                view['light_buffer'][1]).clip(0, 255),
            numpy.subtract(
                numpy.add(
                    numpy.subtract(view['col_buffer'][0][1],
                                   RGB_LIGHT_BUFFER[1]),
                    view['light_buffer'][0]),
                view['light_buffer'][1]).clip(0, 255),
            numpy.subtract(
                numpy.add(
                    numpy.subtract(view['col_buffer'][0][2],
                                   RGB_LIGHT_BUFFER[2]),
                    view['light_buffer'][0]),
                view['light_buffer'][1]).clip(0, 255))

        tcod.console_fill_background(
            view['console'],
            numpy.subtract(
                numpy.add(
                    numpy.subtract(view['col_buffer'][1][0],
                                   RGB_LIGHT_BUFFER[0]),
                    view['light_buffer'][0]),
                view['light_buffer'][1]).clip(0, 255),
            numpy.subtract(
                numpy.add(
                    numpy.subtract(view['col_buffer'][1][1],
                                   RGB_LIGHT_BUFFER[1]),
                    view['light_buffer'][0]),
                view['light_buffer'][1]).clip(0, 255),
            numpy.subtract(
                numpy.add(
                    numpy.subtract(view['col_buffer'][1][2],
                                   RGB_LIGHT_BUFFER[2]),
                    view['light_buffer'][0]),
                view['light_buffer'][1]).clip(0, 255))
    else:
        tcod.console_fill_foreground(view['console'], view['col_buffer'][0][0],
                                     view['col_buffer'][0][1],
                                     view['col_buffer'][0][2])
        tcod.console_fill_background(view['console'], view['col_buffer'][1][0],
                                     view['col_buffer'][1][1],
                                     view['col_buffer'][1][2])

    tcod.console_fill_char(view['console'], view['char_buffer'][0])
Esempio n. 3
0
def _draw_view(view):
	if view['light_buffer']:
		tcod.console_fill_foreground(view['console'],
			numpy.subtract(numpy.add(numpy.subtract(view['col_buffer'][0][0],RGB_LIGHT_BUFFER[0]),view['light_buffer'][0]),view['light_buffer'][1]).clip(0,255),
			numpy.subtract(numpy.add(numpy.subtract(view['col_buffer'][0][1],RGB_LIGHT_BUFFER[1]),view['light_buffer'][0]),view['light_buffer'][1]).clip(0,255),
			numpy.subtract(numpy.add(numpy.subtract(view['col_buffer'][0][2],RGB_LIGHT_BUFFER[2]),view['light_buffer'][0]),view['light_buffer'][1]).clip(0,255))
		
		tcod.console_fill_background(view['console'],
			numpy.subtract(numpy.add(numpy.subtract(view['col_buffer'][1][0],RGB_LIGHT_BUFFER[0]),view['light_buffer'][0]),view['light_buffer'][1]).clip(0,255),
			numpy.subtract(numpy.add(numpy.subtract(view['col_buffer'][1][1],RGB_LIGHT_BUFFER[1]),view['light_buffer'][0]),view['light_buffer'][1]).clip(0,255),
			numpy.subtract(numpy.add(numpy.subtract(view['col_buffer'][1][2],RGB_LIGHT_BUFFER[2]),view['light_buffer'][0]),view['light_buffer'][1]).clip(0,255))
	else:
		tcod.console_fill_foreground(view['console'], view['col_buffer'][0][0], view['col_buffer'][0][1], view['col_buffer'][0][2])
		tcod.console_fill_background(view['console'], view['col_buffer'][1][0], view['col_buffer'][1][1], view['col_buffer'][1][2])
	
	tcod.console_fill_char(view['console'], view['char_buffer'][0])
Esempio n. 4
0
def test_console_fill(console):
    width = libtcodpy.console_get_width(console)
    height = libtcodpy.console_get_height(console)
    fill = [i % 256 for i in range(width * height)]
    libtcodpy.console_fill_background(console, fill, fill, fill)
    libtcodpy.console_fill_foreground(console, fill, fill, fill)
    libtcodpy.console_fill_char(console, fill)

    # verify fill
    bg, fg, ch = [], [], []
    for y in range(height):
        for x in range(width):
            bg.append(libtcodpy.console_get_char_background(console, x, y)[0])
            fg.append(libtcodpy.console_get_char_foreground(console, x, y)[0])
            ch.append(libtcodpy.console_get_char(console, x, y))
    assert fill == bg
    assert fill == fg
    assert fill == ch
Esempio n. 5
0
def update():
	global DRAW_CALLS

	for call in DRAW_CALLS[:constants.MAX_DRAW_CALLS_PER_FRAME]:
		_draw_list = list(call)

		if not _draw_list:
			continue

		for draw in _draw_list:
			surface_name, x, y, c, fore_color, back_color = draw

			_set_char(surface_name, x, y, c, fore_color=fore_color, back_color=back_color)

	DRAW_CALLS = DRAW_CALLS[constants.MAX_DRAW_CALLS_PER_FRAME:]

	tcod.console_set_default_background(0, tcod.dark_gray)
	tcod.console_fill_char(0, SCREEN['c'])
	tcod.console_fill_background(0, SCREEN['b'][0], SCREEN['b'][1], SCREEN['b'][2])
	tcod.console_fill_foreground(0, SCREEN['f'][0], SCREEN['f'][1], SCREEN['f'][2])

	_clear_screen()
	cleanup()
Esempio n. 6
0
def test_console_fill_numpy(console):
    width = libtcodpy.console_get_width(console)
    height = libtcodpy.console_get_height(console)
    fill = numpy.zeros((height, width), dtype=numpy.intc)
    for y in range(height):
        fill[y, :] = y % 256

    libtcodpy.console_fill_background(console, fill, fill, fill)
    libtcodpy.console_fill_foreground(console, fill, fill, fill)
    libtcodpy.console_fill_char(console, fill)

    # verify fill
    bg = numpy.zeros((height, width), dtype=numpy.intc)
    fg = numpy.zeros((height, width), dtype=numpy.intc)
    ch = numpy.zeros((height, width), dtype=numpy.intc)
    for y in range(height):
        for x in range(width):
            bg[y, x] = libtcodpy.console_get_char_background(console, x, y)[0]
            fg[y, x] = libtcodpy.console_get_char_foreground(console, x, y)[0]
            ch[y, x] = libtcodpy.console_get_char(console, x, y)
    fill = fill.tolist()
    assert fill == bg.tolist()
    assert fill == fg.tolist()
    assert fill == ch.tolist()
Esempio n. 7
0
def start_of_frame_terraform():
	tcod.console_fill_background(PREFAB_WINDOW,PREFAB_RGB_BACK_BUFFER[0],PREFAB_RGB_BACK_BUFFER[1],PREFAB_RGB_BACK_BUFFER[2])
	tcod.console_fill_foreground(PREFAB_WINDOW,PREFAB_RGB_FORE_BUFFER[0],PREFAB_RGB_FORE_BUFFER[1],PREFAB_RGB_FORE_BUFFER[2])
	tcod.console_fill_char(PREFAB_WINDOW,PREFAB_CHAR_BUFFER[0])
	
	tcod.console_fill_background(X_CUTOUT_WINDOW,X_CUTOUT_RGB_BACK_BUFFER[0],X_CUTOUT_RGB_BACK_BUFFER[1],X_CUTOUT_RGB_BACK_BUFFER[2])
	tcod.console_fill_foreground(X_CUTOUT_WINDOW,X_CUTOUT_RGB_FORE_BUFFER[0],X_CUTOUT_RGB_FORE_BUFFER[1],X_CUTOUT_RGB_FORE_BUFFER[2])
	tcod.console_fill_char(X_CUTOUT_WINDOW,X_CUTOUT_CHAR_BUFFER[0])
	
	tcod.console_fill_background(Y_CUTOUT_WINDOW,Y_CUTOUT_RGB_BACK_BUFFER[0],Y_CUTOUT_RGB_BACK_BUFFER[1],Y_CUTOUT_RGB_BACK_BUFFER[2])
	tcod.console_fill_foreground(Y_CUTOUT_WINDOW,Y_CUTOUT_RGB_FORE_BUFFER[0],Y_CUTOUT_RGB_FORE_BUFFER[1],Y_CUTOUT_RGB_FORE_BUFFER[2])
	tcod.console_fill_char(Y_CUTOUT_WINDOW,Y_CUTOUT_CHAR_BUFFER[0])
Esempio n. 8
0
def start_of_frame_terraform():
    tcod.console_fill_background(PREFAB_WINDOW, PREFAB_RGB_BACK_BUFFER[0],
                                 PREFAB_RGB_BACK_BUFFER[1],
                                 PREFAB_RGB_BACK_BUFFER[2])
    tcod.console_fill_foreground(PREFAB_WINDOW, PREFAB_RGB_FORE_BUFFER[0],
                                 PREFAB_RGB_FORE_BUFFER[1],
                                 PREFAB_RGB_FORE_BUFFER[2])
    tcod.console_fill_char(PREFAB_WINDOW, PREFAB_CHAR_BUFFER[0])

    tcod.console_fill_background(X_CUTOUT_WINDOW, X_CUTOUT_RGB_BACK_BUFFER[0],
                                 X_CUTOUT_RGB_BACK_BUFFER[1],
                                 X_CUTOUT_RGB_BACK_BUFFER[2])
    tcod.console_fill_foreground(X_CUTOUT_WINDOW, X_CUTOUT_RGB_FORE_BUFFER[0],
                                 X_CUTOUT_RGB_FORE_BUFFER[1],
                                 X_CUTOUT_RGB_FORE_BUFFER[2])
    tcod.console_fill_char(X_CUTOUT_WINDOW, X_CUTOUT_CHAR_BUFFER[0])

    tcod.console_fill_background(Y_CUTOUT_WINDOW, Y_CUTOUT_RGB_BACK_BUFFER[0],
                                 Y_CUTOUT_RGB_BACK_BUFFER[1],
                                 Y_CUTOUT_RGB_BACK_BUFFER[2])
    tcod.console_fill_foreground(Y_CUTOUT_WINDOW, Y_CUTOUT_RGB_FORE_BUFFER[0],
                                 Y_CUTOUT_RGB_FORE_BUFFER[1],
                                 Y_CUTOUT_RGB_FORE_BUFFER[2])
    tcod.console_fill_char(Y_CUTOUT_WINDOW, Y_CUTOUT_CHAR_BUFFER[0])
Esempio n. 9
0
def test_console_fill_errors(console):
    with pytest.raises(TypeError):
        libtcodpy.console_fill_background(console, [0], [], [])
    with pytest.raises(TypeError):
        libtcodpy.console_fill_foreground(console, [0], [], [])
	_RB = zeros((SCREEN_H,SCREEN_W))
	_GB = zeros((SCREEN_H,SCREEN_W))
	_BB = zeros((SCREEN_H,SCREEN_W))
	_RB = add(_RB,255)
	_GB = add(_GB,255)
	_BB = add(_BB,255)
	render = zeros((SCREEN_H,SCREEN_W))
	
	for light in lights:
		if lights.index(light) == 0:
			light['x'] -= 0.01
		
		sqr_distance = (x - light['x'])**2 + (y - light['y'])**2
		
		brightness = light['brightness'] / sqr_distance
		brightness = clip(brightness * 255, 0, 255)
	
		_RB = subtract(_RB,brightness).clip(0,255)
		_GB = subtract(_GB,brightness).clip(0,255)
		_BB = subtract(_BB,brightness).clip(0,255)
	
	_R = subtract(_R,_RB).clip(0,255)
	_G = subtract(_G,_GB).clip(0,255)
	_B = subtract(_B,_BB).clip(0,255)
	
	libtcod.console_fill_background(0, _R, _G, _B)
	libtcod.console_fill_foreground(0, _R, _G, _B)
	print libtcod.sys_get_fps()
	libtcod.console_flush()