def draw_one_tile(tile, location, background_colour=None, orientation=None): location_on_map = Vector( location.x * settings.tile_size.width, location.y * settings.tile_size.height ) worker = None if tile: log('draw_one_tile, orientation {}, {}'.format(orientation, tile)) workers = g.components.filter(on_tile=tile) if workers: worker = workers[0] worker_offset = worker_space_offset(worker.location.space) for is_dark, offset in ( (False, settings.light_map_location), (True, settings.dark_map_location) ): location = location_on_map + offset if tile: if orientation is None: orientation = tile.orientation # TODO: Tidy this up g.images.images[tile.image_name(is_dark)].draw( location=location, orientation=orientation ) if worker and worker.alive is not is_dark: draw_circle(location + worker_offset, settings.worker_circle_size, worker.player.colour_code)
def create_heli_crash(pos, spawn_list): _size = random.randint(4, 6) effects.create_explosion(pos, _size) for n_pos in drawing.draw_circle(pos, _size * 2): if random.randint(0, 10): continue _n_pos = list(n_pos) _n_pos.append(2) effects.create_fire(_n_pos, intensity=8)
def get_spawn_point_around(pos, area=5, min_area=0, chunk_key=False): _positions = [] for next_pos in drawing.draw_circle(pos, area): if bad_numbers.distance(pos, next_pos, old=True) < min_area: continue if next_pos[0]>=MAP_SIZE[0]-1 or next_pos[1]>=MAP_SIZE[1]-1 or next_pos[0]<0 or next_pos[1]<0: continue if list(next_pos) in alife.chunks.get_chunk(alife.chunks.get_chunk_key_at(next_pos))['ground']: _pos = list(next_pos[:2]) _pos.append(2) _positions.append(_pos) if chunk_key: return alife.chunks.get_chunk_key_at(random.choice(_positions)) return random.choice(_positions)
def explode(item): if not item['type'] == 'explosive': return False logging.debug('The %s (item %s) explodes!' % (item['name'], item['uid'])) #TODO: Don't breathe this! item['pos'] = get_pos(item['uid']) if item['damage']['force']: effects.create_explosion(item['pos'], item['damage']['force']) if SETTINGS['controlling'] and alife.sight.can_see_position(LIFE[SETTINGS['controlling']], item['pos']): gfx.message('%s explodes!' % get_name(item)) logic.show_event('%s explodes!' % get_name(item), item=item, delay=0) #elif bad_numbers.distance( #TODO: Dirty hack for life_id in LIFE: _limbs = LIFE[life_id]['body'].keys() if not _limbs: continue _force = bad_numbers.clip((item['damage']['force']*2)-bad_numbers.distance(LIFE[life_id]['pos'], item['pos']), 0, 100) if not _force: continue _known_item = alife.brain.remembers_item(LIFE[life_id], item) _direction = bad_numbers.direction_to(item['pos'], LIFE[life_id]['pos']) #TODO: Intelligent(?) limb groups? _distance = bad_numbers.distance(LIFE[life_id]['pos'], item['pos'])/2 for i in range(_force-_distance): _limb = random.choice(_limbs) for _attached_limb in life.get_all_attached_limbs(LIFE[life_id], _limb): if _attached_limb in _limbs: _limbs.remove(_attached_limb) #_limb = random.choice(LIFE[life_id]['body'].keys()) if _known_item and _known_item['last_seen_time'] < 100 and _known_item['last_owned_by']: life.memory(LIFE[life_id], 'blown_up_by', target=_known_item['last_owned_by']) #for _limb in _limbs: life.add_wound(LIFE[life_id], _limb, force_velocity=bad_numbers.velocity(_direction, _force*2)) if not _limbs: break life.push(LIFE[life_id], _direction, _force) if 'player' in LIFE[life_id]: life.say(LIFE[life_id], '@n are thrown by the explosion!', action=True) else: life.say(LIFE[life_id], '@n is thrown by the explosion!', action=True) if 'fire' in item['damage']: _circle = drawing.draw_circle(item['pos'], item['radius']) _zone = zones.get_zone_at_coords(item['pos']) if _zone: for pos in zones.dijkstra_map(item['pos'], [item['pos']], [_zone], return_score_in_range=[0, item['damage']['fire']]): if not pos in _circle: continue if not maps.position_is_in_map(pos): continue for life_id in LIFE_MAP[pos[0]][pos[1]]: for _visible_item in [get_item_from_uid(i) for i in life.get_all_visible_items(LIFE[life_id])]: if not 'CAN_BURN' in _visible_item['flags']: continue burn(_visible_item, item['damage']['fire']) if not random.randint(0, 4): effects.create_fire((pos[0], pos[1], item['pos'][2]), intensity=item['damage']['fire']/2) _dist = bad_numbers.distance(item['pos'], pos)/2 if not random.randint(0, _dist) or not _dist: effects.create_ash(pos) if gfx.position_is_in_frame(pos): _render_pos = gfx.get_render_position(pos) gfx.refresh_view_position(_render_pos[0], _render_pos[1], 'map') #if item['uid'] in ITEMS and ITEMS[item['uid']]['owner'] and item['uid'] in LIFE[ITEMS[item['uid']]['owner']]['inventory']: delete_item(item)
def explode(item): if not item['type'] == 'explosive': return False logging.debug('The %s (item %s) explodes!' % (item['name'], item['uid'])) #TODO: Don't breathe this! item['pos'] = get_pos(item['uid']) if item['damage']['force']: effects.create_explosion(item['pos'], item['damage']['force']) if SETTINGS['controlling'] and alife.sight.can_see_position( LIFE[SETTINGS['controlling']], item['pos']): gfx.message('%s explodes!' % get_name(item)) logic.show_event('%s explodes!' % get_name(item), item=item, delay=0) #elif bad_numbers.distance( #TODO: Dirty hack for life_id in LIFE: _limbs = LIFE[life_id]['body'].keys() if not _limbs: continue _force = bad_numbers.clip( (item['damage']['force'] * 2) - bad_numbers.distance(LIFE[life_id]['pos'], item['pos']), 0, 100) if not _force: continue _known_item = alife.brain.remembers_item(LIFE[life_id], item) _direction = bad_numbers.direction_to(item['pos'], LIFE[life_id]['pos']) #TODO: Intelligent(?) limb groups? _distance = bad_numbers.distance(LIFE[life_id]['pos'], item['pos']) / 2 for i in range(_force - _distance): _limb = random.choice(_limbs) for _attached_limb in life.get_all_attached_limbs( LIFE[life_id], _limb): if _attached_limb in _limbs: _limbs.remove(_attached_limb) #_limb = random.choice(LIFE[life_id]['body'].keys()) if _known_item and _known_item[ 'last_seen_time'] < 100 and _known_item['last_owned_by']: life.memory(LIFE[life_id], 'blown_up_by', target=_known_item['last_owned_by']) #for _limb in _limbs: life.add_wound(LIFE[life_id], _limb, force_velocity=bad_numbers.velocity( _direction, _force * 2)) if not _limbs: break life.push(LIFE[life_id], _direction, _force) if 'player' in LIFE[life_id]: life.say(LIFE[life_id], '@n are thrown by the explosion!', action=True) else: life.say(LIFE[life_id], '@n is thrown by the explosion!', action=True) if 'fire' in item['damage']: _circle = drawing.draw_circle(item['pos'], item['radius']) _zone = zones.get_zone_at_coords(item['pos']) if _zone: for pos in zones.dijkstra_map( item['pos'], [item['pos']], [_zone], return_score_in_range=[0, item['damage']['fire']]): if not pos in _circle: continue if not maps.position_is_in_map(pos): continue for life_id in LIFE_MAP[pos[0]][pos[1]]: for _visible_item in [ get_item_from_uid(i) for i in life.get_all_visible_items(LIFE[life_id]) ]: if not 'CAN_BURN' in _visible_item['flags']: continue burn(_visible_item, item['damage']['fire']) if not random.randint(0, 4): effects.create_fire((pos[0], pos[1], item['pos'][2]), intensity=item['damage']['fire'] / 2) _dist = bad_numbers.distance(item['pos'], pos) / 2 if not random.randint(0, _dist) or not _dist: effects.create_ash(pos) if gfx.position_is_in_frame(pos): _render_pos = gfx.get_render_position(pos) gfx.refresh_view_position(_render_pos[0], _render_pos[1], 'map') #if item['uid'] in ITEMS and ITEMS[item['uid']]['owner'] and item['uid'] in LIFE[ITEMS[item['uid']]['owner']]['inventory']: delete_item(item)
def drawvertex(v): a, b = pos[v] draw_circle(a, b, radius) draw_label(str(v), a, b)