Beispiel #1
0
def draw_dialog(dialog_id):
	_dialog = get_dialog(dialog_id)
	_last_message = get_last_message(dialog_id)
	_x = numbers.clip(MAP_WINDOW_SIZE[0]/2-len(_last_message['text'])/2, 3, 100)
	_y = 10
	_line_of_sight = drawing.diag_line(LIFE[_dialog['started_by']]['pos'], LIFE[_dialog['target']]['pos'])
	
	locks.unlock('camera_free')
	
	if len(_line_of_sight)<=1:
		_center_pos = LIFE[_dialog['started_by']]['pos']
	else:
		_center_pos = list(_line_of_sight[len(_line_of_sight)/2])
		_center_pos.append(2)
	
	if SETTINGS['controlling'] == _dialog['started_by']:
		_target = _dialog['target']
	else:
		_target = _dialog['started_by']
	
	_target_portrait = lfe.draw_life_icon(LIFE[_target])
	_lines = []
	                                   
	gfx.camera_track(_center_pos)
	gfx.blit_string(_x-2, _y-2, ' '.join(LIFE[_target]['name']), 'overlay', fore_color=_target_portrait[1])
	gfx.blit_string(_x-2, _y, _target_portrait[0], 'overlay', fore_color=_target_portrait[1])#, back_color=tcod.darkest_gray)
	
	_text = _last_message['text']
	_y_mod = 0
	while _text:
		_x = MAP_WINDOW_SIZE[0]/2-len(_text[:MAP_WINDOW_SIZE[0]-4])/2
		
		gfx.blit_string(_x, _y+_y_mod, _text[:MAP_WINDOW_SIZE[0]-4], 'overlay')
		_text = _text[MAP_WINDOW_SIZE[0]-4:]
		_y_mod += 1
	
	for choice in _dialog['choices']:
		_text = choice['text'][choice['text'].index('\"')+1:choice['text'].index('\"')-1]
		
		if not _text.startswith('>'):
			_text = '> '+_text
		
		_n_x = MAP_WINDOW_SIZE[0]/2-len(_text)/2
		
		if _n_x < _x:
			_x = _n_x
	
	for choice in _dialog['choices']:
		_text = choice['text'][choice['text'].index('\"')+1:choice['text'].index('\"')-1]
		
		if _dialog['cursor_index'] == _dialog['choices'].index(choice):
			_text = '> '+_text
		
		_lines.append(_text)
	
	for line in _lines:
		gfx.blit_string(_x, _y+3, line, 'overlay')#, back_color=tcod.darkest_gray)
		_y += 2
Beispiel #2
0
def draw_event():
	_event = None
	
	for event in EVENTS:
		if not event['delay']:
			_event = event
			break
	
	if not _event:
		return False
	
	locks.unlock('camera_free')
	gfx.camera_track(_event['pos'])
	
	if len(event['text'])>=MAP_WINDOW_SIZE[0]-1:
		_lines = list(_event['text'].partition(','))
		
		if not len(_lines[1]):
			_lines = list(_event['text'].partition('.'))
		
		if len(_lines[1]):
			_lines.pop(1)
		else:
			lines = ['????']
		
	else:
		_lines = [_event['text']]
	
	for line in _lines:
		if len(line)>=MAP_WINDOW_SIZE[0]-1:
			_lines = ['The most annoying error.']
			break	
	
	_i = 0
	for line in _lines:
		_half = len(line)/2
		_x = bad_numbers.clip((MAP_WINDOW_SIZE[0]/2)-_half, 0, MAP_WINDOW_SIZE[0]-len(line)-1)
		
		gfx.blit_string(_x,
			10+_i,
			line,
		    'overlay')
		
		_i += 1
	
	return True
Beispiel #3
0
def death():
    FADE_TO_WHITE[0] += 0.5

    _time_since_death = FADE_TO_WHITE[0]
    _time_alive = numbers.clip(
        (LIFE[SETTINGS["controlling"]]["time_of_death"] - LIFE[SETTINGS["controlling"]]["created"])
        / float(WORLD_INFO["length_of_day"]),
        0.1,
        9999,
    )
    _string = "You die."
    _sub_string = LIFE[SETTINGS["controlling"]]["cause_of_death"]
    _col = int(round(255 * numbers.clip((_time_since_death / 100.0) - random.uniform(0, 0.15), 0, 1)))

    if _time_alive == 1:
        _sub_sub_string = "Lived 1 day"
    else:
        _sub_sub_string = "Lived %s days" % (_time_alive)

    gfx.fade_to_black(1)

    gfx.blit_string(
        (MAP_WINDOW_SIZE[0] / 2) - len(_string) / 2,
        MAP_WINDOW_SIZE[1] / 2,
        _string,
        "map",
        fore_color=tcod.Color(_col, 0, 0),
        back_color=tcod.Color(0, 0, 0),
    )

    gfx.blit_string(
        (MAP_WINDOW_SIZE[0] / 2) - len(_sub_string) / 2,
        (MAP_WINDOW_SIZE[1] / 2) + 2,
        _sub_string,
        "map",
        fore_color=tcod.Color(int(round(_col * 0.75)), int(round(_col * 0.75)), int(round(_col * 0.75))),
        back_color=tcod.Color(0, 0, 0),
    )

    gfx.blit_string(
        (MAP_WINDOW_SIZE[0] / 2) - len(_sub_sub_string) / 2,
        (MAP_WINDOW_SIZE[1] / 2) + 4,
        _sub_sub_string,
        "map",
        fore_color=tcod.Color(int(round(_col * 0.75)), int(round(_col * 0.75)), int(round(_col * 0.75))),
        back_color=tcod.Color(0, 0, 0),
    )

    if _time_since_death >= 350:
        worldgen.save_world()
        worldgen.reset_world()

        gfx.clear_scene()

        SETTINGS["running"] = 1
        return False

    return True
Beispiel #4
0
def death():
	_player = LIFE[SETTINGS['controlling']]
	
	maps.reset_lights()
	FADE_TO_WHITE[0] += .5
	
	_time_since_death = FADE_TO_WHITE[0]
	_time_alive = round(numbers.clip((_player['time_of_death']-_player['created'])/float(WORLD_INFO['length_of_day']), 0.1, 9999), 2)
	_string = 'You die.'
	_sub_string = _player['cause_of_death']
	_col = int(round(255*numbers.clip((_time_since_death/100.0)-random.uniform(0, 0.15), 0, 1)))
	
	
	if _time_alive == 1:
		_sub_sub_string = 'Lived 1 day'
	else:
		if _time_alive < 1:
			_sub_sub_string = 'Lived less than a day'
		else:
			_sub_sub_string = 'Lived %0.1f days' % (_time_alive)
	
	gfx.fade_to_black(1)	
	
	gfx.blit_string((MAP_WINDOW_SIZE[0]/2)-len(_string)/2,
	                MAP_WINDOW_SIZE[1]/2,
	                _string,
	                'map',
	                fore_color=tcod.Color(_col, 0, 0),
	                back_color=tcod.Color(0, 0, 0))
	
	gfx.blit_string((MAP_WINDOW_SIZE[0]/2)-len(_sub_string)/2,
	                (MAP_WINDOW_SIZE[1]/2)+2,
	                _sub_string,
	                'map',
	                fore_color=tcod.Color(int(round(_col*.75)), int(round(_col*.75)), int(round(_col*.75))),
	                back_color=tcod.Color(0, 0, 0))
	
	gfx.blit_string((MAP_WINDOW_SIZE[0]/2)-len(_sub_sub_string)/2,
	                (MAP_WINDOW_SIZE[1]/2)+4,
	                _sub_sub_string,
	                'map',
	                fore_color=tcod.Color(int(round(_col*.75)), int(round(_col*.75)), int(round(_col*.75))),
	                back_color=tcod.Color(0, 0, 0))
	
	if _time_since_death>=350:
		worldgen.save_world()
		worldgen.reset_world()

		gfx.clear_scene()
		
		SETTINGS['running'] = 1
		return False
	
	return True
Beispiel #5
0
def death():
    _player = LIFE[SETTINGS['controlling']]

    maps.reset_lights()
    FADE_TO_WHITE[0] += .5

    _time_since_death = FADE_TO_WHITE[0]
    _time_alive = round(
        numbers.clip((_player['time_of_death'] - _player['created']) /
                     float(WORLD_INFO['length_of_day']), 0.1, 9999), 2)
    _string = 'You die.'
    _sub_string = _player['cause_of_death']
    _col = int(
        round(255 * numbers.clip(
            (_time_since_death / 100.0) - random.uniform(0, 0.15), 0, 1)))

    if _time_alive == 1:
        _sub_sub_string = 'Lived 1 day'
    else:
        if _time_alive < 1:
            _sub_sub_string = 'Lived less than a day'
        else:
            _sub_sub_string = 'Lived %0.1f days' % (_time_alive)

    gfx.fade_to_black(1)

    gfx.blit_string((MAP_WINDOW_SIZE[0] / 2) - len(_string) / 2,
                    MAP_WINDOW_SIZE[1] / 2,
                    _string,
                    'map',
                    fore_color=tcod.Color(_col, 0, 0),
                    back_color=tcod.Color(0, 0, 0))

    gfx.blit_string((MAP_WINDOW_SIZE[0] / 2) - len(_sub_string) / 2,
                    (MAP_WINDOW_SIZE[1] / 2) + 2,
                    _sub_string,
                    'map',
                    fore_color=tcod.Color(int(round(_col * .75)),
                                          int(round(_col * .75)),
                                          int(round(_col * .75))),
                    back_color=tcod.Color(0, 0, 0))

    gfx.blit_string((MAP_WINDOW_SIZE[0] / 2) - len(_sub_sub_string) / 2,
                    (MAP_WINDOW_SIZE[1] / 2) + 4,
                    _sub_sub_string,
                    'map',
                    fore_color=tcod.Color(int(round(_col * .75)),
                                          int(round(_col * .75)),
                                          int(round(_col * .75))),
                    back_color=tcod.Color(0, 0, 0))

    if _time_since_death >= 350:
        worldgen.save_world()
        worldgen.reset_world()

        gfx.clear_scene()

        SETTINGS['running'] = 1
        return False

    return True
Beispiel #6
0
def draw_dialog(dialog_id):
    _dialog = get_dialog(dialog_id)
    _last_message = get_last_message(dialog_id)
    _x = bad_numbers.clip(
        MAP_WINDOW_SIZE[0] / 2 - len(_last_message['text']) / 2, 3, 100)
    _y = 10
    _line_of_sight = drawing.diag_line(LIFE[_dialog['started_by']]['pos'],
                                       LIFE[_dialog['target']]['pos'])

    locks.unlock('camera_free')

    if len(_line_of_sight) <= 1:
        _center_pos = LIFE[_dialog['started_by']]['pos']
    else:
        _center_pos = list(_line_of_sight[len(_line_of_sight) / 2])
        _center_pos.append(2)

    if SETTINGS['controlling'] == _dialog['started_by']:
        _target = _dialog['target']
    else:
        _target = _dialog['started_by']

    _target_portrait = lfe.draw_life_icon(LIFE[_target])
    _lines = []

    gfx.camera_track(_center_pos)
    gfx.blit_string(_x - 2,
                    _y - 2,
                    ' '.join(LIFE[_target]['name']),
                    'overlay',
                    fore_color=_target_portrait[1])
    gfx.blit_string(
        _x - 2,
        _y,
        _target_portrait[0],
        'overlay',
        fore_color=_target_portrait[1])  #, back_color=tcod.darkest_gray)

    _text = _last_message['text']
    _y_mod = 0
    while _text:
        _x = MAP_WINDOW_SIZE[0] / 2 - len(_text[:MAP_WINDOW_SIZE[0] - 4]) / 2

        gfx.blit_string(_x, _y + _y_mod, _text[:MAP_WINDOW_SIZE[0] - 4],
                        'overlay')
        _text = _text[MAP_WINDOW_SIZE[0] - 4:]
        _y_mod += 1

    for choice in _dialog['choices']:
        _text = choice['text'][choice['text'].index('\"') +
                               1:choice['text'].index('\"') - 1]

        if not _text.startswith('>'):
            _text = '> ' + _text

        _n_x = MAP_WINDOW_SIZE[0] / 2 - len(_text) / 2

        if _n_x < _x:
            _x = _n_x

    for choice in _dialog['choices']:
        _text = choice['text'][choice['text'].index('\"') +
                               1:choice['text'].index('\"') - 1]

        if _dialog['cursor_index'] == _dialog['choices'].index(choice):
            _text = '> ' + _text

        _lines.append(_text)

    for line in _lines:
        gfx.blit_string(_x, _y + 3, line,
                        'overlay')  #, back_color=tcod.darkest_gray)
        _y += 2