Пример #1
0
def create_smoke_streamer(pos, size, length, color=tcod.gray):
	_direction = random.randint(0, 359)
	_end_velocity = numbers.velocity(_direction, length)
	_end_pos = [int(round(pos[0]+_end_velocity[0])), int(round(pos[1]+_end_velocity[1]))]
	
	for new_pos in render_los.draw_line(pos[0], pos[1], _end_pos[0], _end_pos[1]):
		_new_pos = [new_pos[0], new_pos[1], pos[2]]
		create_smoke_cloud(_new_pos, size, age=-numbers.distance(pos, new_pos)/float(length), color=color)
Пример #2
0
def _can_see_position(pos1,
                      pos2,
                      max_length=10,
                      block_check=False,
                      strict=False,
                      distance=True):
    if block_check:
        _check = [(-1, -1), (1, -1), (0, 0), (-1, 1), (1, 1)]
    else:
        _check = [(0, 0)]

    _ret_line = []
    for _pos in _check:
        _line = render_los.draw_line(pos1[0], pos1[1], pos2[0], pos2[1])

        if not _line:
            _line = []

        if _pos == (0, 0):
            _ret_line = _line

        if len(_line) > max_length and distance:
            _ret_line = []
            continue

        for pos in _line:
            _chunk = chunks.get_chunk_from_cache(pos)

            #for item_uid in _chunk['items'][:]:
            #	if not item_uid in ITEMS:
            #		_chunk['items'].remove(item_uid)

            #for item in [ITEMS[uid] for uid in _chunk['items'] if items.is_blocking(uid)]:
            #	if tuple(item['pos'])[:2] == tuple(pos2)[:2]:
            #		continue
            #
            #	if (pos[0], pos[1]) == tuple(item['pos'])[:2]:
            #		_ret_line = []
            #		if strict:
            #			return False
            #
            #		continue

            if maps.is_solid((pos[0], pos[1], pos1[2] + 1)):
                _ret_line = []
                if strict:
                    return False

                continue

    return _ret_line
Пример #3
0
def _can_see_position(pos1, pos2, max_length=10, block_check=False, strict=False, distance=True):
	if block_check:
		_check = [(-1, -1), (1, -1), (0, 0), (-1, 1), (1, 1)]
	else:
		_check = [(0, 0)]
	
	_ret_line = []
	for _pos in _check:
		_line = render_los.draw_line(pos1[0],
		                             pos1[1],
		                             pos2[0],
		                             pos2[1])
										 
		if not _line:
			_line = []
		
		if _pos == (0, 0):
			_ret_line = _line
		
		if len(_line) > max_length and distance:
			_ret_line = []
			continue
		
		for pos in _line:
			_chunk = chunks.get_chunk_from_cache(pos)
			
			#for item_uid in _chunk['items'][:]:
			#	if not item_uid in ITEMS:
			#		_chunk['items'].remove(item_uid)
			
			#for item in [ITEMS[uid] for uid in _chunk['items'] if items.is_blocking(uid)]:
			#	if tuple(item['pos'])[:2] == tuple(pos2)[:2]:
			#		continue
			#	
			#	if (pos[0], pos[1]) == tuple(item['pos'])[:2]:
			#		_ret_line = []
			#		if strict:
			#			return False
			#		
			#		continue
				
			if maps.is_solid((pos[0], pos[1], pos1[2]+1)):
				_ret_line = []
				if strict:
					return False
				
				continue
	
	return _ret_line
Пример #4
0
def create_smoke_streamer(pos, size, length, color=tcod.gray):
    _direction = random.randint(0, 359)
    _end_velocity = numbers.velocity(_direction, length)
    _end_pos = [
        int(round(pos[0] + _end_velocity[0])),
        int(round(pos[1] + _end_velocity[1]))
    ]

    for new_pos in render_los.draw_line(pos[0], pos[1], _end_pos[0],
                                        _end_pos[1]):
        _new_pos = [new_pos[0], new_pos[1], pos[2]]
        create_smoke_cloud(_new_pos,
                           size,
                           age=-numbers.distance(pos, new_pos) / float(length),
                           color=color)
Пример #5
0
def short_path(life, start, end):
	_s = time.time()
	_line = render_los.draw_line(start[0], start[1], end[0], end[1])
	
	if bad_numbers.distance(start, end)>30:
		return False
	
	if not _line:
		return [start]
	
	_line.pop(0)
	
	for pos in _line:
		if not lfe.can_traverse(life, pos):
			return False
	
	return _line