def create_laser(x, y, direction, owner_id, damage=12, length=20): _vel = numbers.velocity(direction, length) for i in range(length): _vel = numbers.velocity(direction, 3*(length*i)) _bullet = create(x+_vel[0], y+_vel[1], direction, 0, 'laser.png', owner_id, damage=damage, life=10) entities.trigger_event(_bullet, 'set_rotation', degrees=direction) entities.register_event(_bullet, 'hit', hit_laser)
def create_smoke(pos, color=tcod.gray, age=0, grow=0.1, decay=0.1, direction=-1, speed=0.3, max_opacity=.75, interp_wind=True): _intensity = random.uniform(max_opacity*.25, max_opacity) _color = tcod.color_lerp(color, tcod.white, random.uniform(0, 0.3)) if direction == -1: _velocity = [random.uniform(-speed, speed), random.uniform(-speed, speed), 0] else: _velocity = numbers.velocity(direction, speed) _effect = {'type': 'smoke', 'color': _color, 'intensity': _intensity*age, 'max_intensity': _intensity, 'decay': decay, 'grow': grow, 'disappear': False, 'pos': list(pos), 'float_pos': list(pos), 'interp_wind': interp_wind, 'velocity': [_velocity[0], _velocity[1], _velocity[2]], 'callback': process_smoke, 'draw_callback': draw_smoke, 'unregister_callback': clear_effect} register_effect(_effect)
def tick(entity): entity['recoil_time'] -= 1 if not entity['owner_id'] in entities.ENTITIES: entities.unregister_event(entity, 'tick', tick) return False if entity['recoil_time']>0: return False elif not entity['rounds']: if entity['reload_time']: if entity['owner_id'] in entities.ENTITIES and 'player' in entities.get_entity(entity['owner_id']) and entity['reload_time'] == entity['reload_time_max']: display.print_text(0, 0, 'RELOADING', show_for=(entity['reload_time']/display.get_tps())*2, fade_out_speed=255) entity['reload_time'] -= 1 else: entity['reload_time'] = entity['reload_time_max'] entity['recoil_time'] = 1 entity['rounds'] = entity['max_rounds'] entity['firing'] = False entities.unregister_event(entity, 'tick', tick) return False _owner = entities.get_entity(entity['owner_id']) if 'shoot_direction' in entity: _direction = entity['shoot_direction'] elif 'shoot_direction' in _owner: _direction = _owner['shoot_direction'] else: _direction = _owner['direction'] if entity['kickback']: entities.trigger_event(entities.get_entity(entity['owner_id']), 'push', velocity=numbers.velocity(_direction+180, entity['kickback'])) if entity['missile']: bullet.create_missile(_owner['position'][0], _owner['position'][1], _direction, entity['speed'], 'bullet.png', entity['owner_id'], turn_rate=entity['turn_rate'], tracking=entity['tracking'], radius=entity['damage_radius']) if entity['bullet']: bullet.create_bullet(_owner['position'][0], _owner['position'][1], _direction+random.randint(-entity['spray'], entity['spray']), entity['speed'], 'bullet.png', entity['owner_id'], scale=.6, radius=entity['damage_radius']) entity['recoil_time'] = entity['recoil_time_max'] entity['rounds'] -= 1
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)
def tick_particle(particle): if particle['spin']: entities.trigger_event(particle, 'rotate_by', degrees=particle['spin']) if particle['fade_rate']: entities.trigger_event(particle, 'fade_by', amount=particle['fade_rate']) particle['sprite'].visible = True if particle['swerve_rate']: particle['direction'] += (random.randint(int(round(particle['swerve_rate']*.25)), particle['swerve_rate'])*particle['swerve_speed']/float(particle['swerve_speed_max']))*random.choice([-1, 1]) particle['velocity'] = numbers.velocity(particle['direction'], particle['swerve_speed']) particle['swerve_speed'] -= 1 if particle['swerve_speed']<=0: entities.delete_entity(particle) return False if particle['flashes']>-1: if random.uniform(0, 1)>1-particle['flash_chance']: particle['sprite'].visible = False particle['flashes'] -= 1 if not particle['flashes']: entities.delete_entity(particle) return False if particle['streamer'] and random.uniform(0, 1)>1-particle['streamer_chance']: if particle['swerve_rate']: _image = 'streamer.png' else: _image = particle['sprite_name'] _effect = create_particle(particle['position'][0], particle['position'][1], _image, background=particle['background'], direction=particle['direction'], rotation=particle['direction'], scale=particle['sprite'].scale, scale_min=particle['scale_min'], scale_rate=particle['scale_rate']) if particle['swerve_rate']: entities.trigger_event(_effect, 'set_rotation', degrees=particle['direction']) entities.trigger_event(_effect, 'set_scale', scale=particle['swerve_speed']/float(particle['swerve_speed_max'])) _effect['sprite'].opacity = 255*particle['swerve_speed']/float(particle['swerve_speed_max']) if not particle['scale_rate'] == 1: if particle['sprite'].scale < particle['scale_min']: entities.delete_entity(particle) elif particle['sprite'].scale > particle['scale_max']: entities.delete_entity(particle) else: entities.trigger_event(particle, 'set_scale', scale=particle['sprite'].scale*particle['scale_rate'])
def move(item, direction, speed, friction=0.05, _velocity=0): """Sets new velocity for an item. Returns nothing.""" velocity = numbers.velocity(direction, speed) velocity[2] = _velocity item['speed'] = speed item['friction'] = friction item['velocity'] = velocity item['realpos'] = item['pos'][:] logging.debug('%s flies off in an arc! (%s)' % (get_name(item), item['velocity']))
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)
def _gravity_well(entity): _moving_groups = [name for name in entities.GROUPS if not name in entity['_groups'] and not name in entities.IGNORE_ENTITY_GROUPS] for entity_id in entities.get_sprite_groups(_moving_groups): _entity = entities.get_entity(entity_id) if numbers.distance(entity['position'], _entity['position'])<entity['min_distance']: _entity['in_space'] = False continue if entity['kill_engines']: _entity['in_space'] = True _velocity = numbers.velocity(numbers.direction_to(_entity['position'], entity['position']), entity['strength']) entities.trigger_event(_entity, 'push', velocity=_velocity)
def create_smoke(pos, color=tcod.gray, age=0, grow=0.1, decay=0.1, direction=-1, speed=0.3, max_opacity=.75, interp_wind=True): _intensity = random.uniform(max_opacity * .25, max_opacity) _color = tcod.color_lerp(color, tcod.white, random.uniform(0, 0.3)) if direction == -1: _velocity = [ random.uniform(-speed, speed), random.uniform(-speed, speed), 0 ] else: _velocity = numbers.velocity(direction, speed) _effect = { 'type': 'smoke', 'color': _color, 'intensity': _intensity * age, 'max_intensity': _intensity, 'decay': decay, 'grow': grow, 'disappear': False, 'pos': list(pos), 'float_pos': list(pos), 'interp_wind': interp_wind, 'velocity': [_velocity[0], _velocity[1], _velocity[2]], 'callback': process_smoke, 'draw_callback': draw_smoke, 'unregister_callback': clear_effect } register_effect(_effect)
def ivan_cycles(entity): if entity['warmup_cycles']: entity['warmup_cycles'] -= 1 return False if entity['cycle'] == 'shoot': #if entity['shoot_cycle'] == entity['shoot_cycle_max']: # for i in range(8): # bullet.create_laser(entity['position'][0], entity['position'][0], 45*(i+1), entity['_id'], damage=30, length=90) entity['shoot_cycle'] -= 1 if not entity['shoot_cycle']: entity['shoot_cycle'] = entity['shoot_cycle_max'] entity['cycle'] = 'spawn' for direction in range(0, 360, 15): for i in range(4): bullet.create_bullet(entity['position'][0], entity['position'][1], direction+4*i, 60+(i*10), 'boss3_core.png', entity['_id'], damage=15) else: entity['spawn_cycle'] -= 1 if not entity['spawn_cycle']: entity['spawn_cycle'] = entity['shoot_cycle_max'] entity['cycle'] = 'shoot' for i in range(5): _mine = create_eyemine(x=entity['position'][0], y=entity['position'][1], max_explode_velocity=90) entities.trigger_event(_mine, 'push', velocity=numbers.velocity(random.randint(0, 359), 65))
def tick_drunk(bullet): bullet['direction'] += random.randint(-6, 6) bullet['velocity'] = numbers.velocity(bullet['direction']+random.randint(-12, 12), bullet['speed'])
def hurt_player(situation): _player = LIFE[SETTINGS['controlling']] if situation['group']: if situation['armed']: _bandit_group_leader = get_group_leader_with_motive('crime', online=True) _military_group_leader = get_group_leader_with_motive('military', online=False) if not _military_group_leader: _military_group_leader = spawns.generate_group('soldier', amount=3, spawn_chunks=[spawns.get_spawn_in_ref('outposts', chunk_key=True)])[0] if not _bandit_group_leader: _chunk_key = alife.chunks.get_chunk_key_at(spawns.get_spawn_point_around(_military_group_leader['pos'], area=150, min_area=100)) _bandit_group_leader = spawns.generate_group('bandit', amount=5, spawn_chunks=[_chunk_key])[0] _bandit_group_location = lfe.get_current_chunk_id(_bandit_group_leader) _military_group_location = lfe.get_current_chunk_id(_military_group_leader) order_group(_bandit_group_leader, _bandit_group_leader['group'], STAGE_RAIDING, 500, chunk_key=_military_group_location) alife.groups.discover_group(_bandit_group_leader, _military_group_leader['group']) alife.groups.declare_group_hostile(_bandit_group_leader, _bandit_group_leader['group'], _military_group_leader['group']) _real_direction = language.get_real_direction(numbers.direction_to((MAP_SIZE[0]/2, MAP_SIZE[1]/2), alife.chunks.get_chunk(_military_group_location)['pos'])) _messages = [{'text': 'Attention all neutral and bandit squads.'}, {'text': 'We finally got solid contact on military in the %s compound.' % _real_direction}, {'text': 'We\'re located near coords %s and heading out soon.' % (', '.join(_bandit_group_location.split(',')))}] events.broadcast(_messages, 40) core.record_encounter(len(alife.groups.get_group(_military_group_leader, _military_group_leader['group'])['members'])) _player_group_leader = LIFE[alife.groups.get_leader(_player, situation['group'])] for friendly_member in alife.groups.get_group(_player_group_leader, situation['group'])['members']: for hostile_member in alife.groups.get_group(_military_group_leader, _military_group_leader['group'])['members']: _target = alife.brain.meet_alife(LIFE[friendly_member], LIFE[hostile_member]) _target['last_seen_time'] = 1 _target['escaped'] = 1 _target['last_seen_at'] = LIFE[hostile_member]['pos'][:] alife.stats.establish_hostile(LIFE[friendly_member], hostile_member) for hostile_member in alife.groups.get_group(_military_group_leader, _military_group_leader['group'])['members']: for friendly_member in alife.groups.get_group(_player_group_leader, situation['group'])['members']: _target = alife.brain.meet_alife(LIFE[hostile_member], LIFE[friendly_member]) _target['last_seen_time'] = 1 _target['escaped'] = 1 _target['last_seen_at'] = LIFE[friendly_member]['pos'][:] alife.stats.establish_hostile(LIFE[hostile_member], friendly_member) return True elif situation['armed']: _town_chunk_keys = [] for ref in WORLD_INFO['refs']['towns']: _town_chunk_keys.extend(ref) _nearest_town_chunk_key = alife.chunks.get_nearest_chunk_in_list(_player['pos'], _town_chunk_keys) _town_chunk = alife.chunks.get_chunk(_nearest_town_chunk_key) _distance_to_nearst_town = numbers.distance(_player['pos'], _town_chunk['pos']) _spawn_distance = 15*WORLD_INFO['chunk_size'] if len(situation['online_alife']) == len(situation['trusted_online_alife']): if _distance_to_nearst_town<=50: _group_spawn_velocity = numbers.velocity(numbers.direction_to(_player['pos'], _town_chunk['pos']), _spawn_distance+(50-numbers.clip(_distance_to_nearst_town, 0, 50))) _group_spawn_pos = [int(round(_player['pos'][0]+_group_spawn_velocity[0])), int(round(_player['pos'][1]+_group_spawn_velocity[1]))] _group_spawn_pos[0] = numbers.clip(_group_spawn_pos[0], 0, MAP_SIZE[0]) _group_spawn_pos[1] = numbers.clip(_group_spawn_pos[1], 0, MAP_SIZE[1]) _group_spawn_chunk_key = alife.chunks.get_chunk_key_at(spawns.get_spawn_point_around(_group_spawn_pos, area=30)) _alife = spawns.generate_group('bandit', amount=2, spawn_chunks=[_group_spawn_chunk_key]) for ai in _alife: alife.brain.meet_alife(ai, _player) alife.stats.establish_hostile(ai, _player['id']) core.record_encounter(2, life_ids=[i['id'] for i in _alife]) if random.randint(0, 1) or 1: _spawn_chunk_key = spawns.get_spawn_point_around(_group_spawn_pos, area=90, min_area=60, chunk_key=True) _other_group = spawns.generate_group('loner', amount=1, spawn_chunks=[_spawn_chunk_key]) for ai in _other_group: for ai2 in _alife: _target = alife.brain.meet_alife(ai, ai2) _target['last_seen_time'] = 1 _target['escaped'] = 1 _target['last_seen_at'] = ai2['pos'][:] alife.stats.establish_hostile(ai, ai2['id']) for ai2 in _alife: for ai in _other_group: _target = alife.brain.meet_alife(ai2, ai) _target['last_seen_time'] = 1 _target['escaped'] = 1 _target['last_seen_at'] = ai['pos'][:] alife.stats.establish_hostile(ai2, ai['id']) _messages = [{'text': 'I\'m pinned down in the village!'}, {'text': 'Anyone nearby?'}] events.broadcast(_messages, 0) return True elif 1==2: _spawn_chunk_key = spawns.get_spawn_point_around(_player['pos'], min_area=125, area=200, chunk_key=True) _group = spawns.generate_group('loner', amount=1, spawn_chunks=[_spawn_chunk_key]) core.record_encounter(1, life_ids=[l['id'] for l in _group]) for ai in _group: events.attract_tracked_alife_to(spawns.get_spawn_point_around(_player['pos'], min_area=10, area=100)) return False
def get_wind_velocity(): #return get_current_weather()['name'] return numbers.velocity(175+random.randint(-15, 15), .8)
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 numbers.distance( #TODO: Dirty hack for life_id in LIFE: _limbs = LIFE[life_id]['body'].keys() if not _limbs: continue _force = numbers.clip((item['damage']['force']*2)-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 = numbers.direction_to(item['pos'], LIFE[life_id]['pos']) #TODO: Intelligent(?) limb groups? _distance = 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=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 = 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']) alife.noise.create(item['pos'], item['damage']['force']*100, 'an explosion', 'a low rumble') if item['damage']['force']: effects.create_light(item['pos'], (255, 69, 0), item['damage']['force']*6, 1, fade=3) effects.create_smoke_cloud(item['pos'], item['damage']['force']*6, age=.8, factor_distance=True) for i in range(random.randint(1, 3)): effects.create_smoke_streamer(item['pos'], 3+random.randint(0, 2), (item['damage']['force']*2)+random.randint(3, 6), color=tcod.color_lerp(tcod.gray, tcod.crimson, random.uniform(0.1, 0.3))) 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 numbers.distance( #TODO: Dirty hack for life_id in LIFE: _limbs = LIFE[life_id]['body'].keys() if not _limbs: continue _force = numbers.clip((item['damage']['force']*2)-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 = numbers.direction_to(item['pos'], LIFE[life_id]['pos']) #TODO: Intelligent(?) limb groups? _distance = 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()) #ex: memory(life, 'shot at by (missed)', target=item['owner'], danger=3, trust=-10) 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'], trust=-10, danger=3) #for _limb in _limbs: life.add_wound(LIFE[life_id], _limb, force_velocity=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 = 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 spawn_enemies(): global TRANSITION_PAUSE, CHANGE_WAVE_FIRE, CHANGE_WAVE, ANNOUNCE, WAVE _i = random.choice([0, 1, 2, 3]) if WAVE == 3: TRANSITION_PAUSE = 30*30 CHANGE_WAVE = True CHANGE_WAVE_FIRE = False return False if LEVEL == 2: return False if _i == 1: _xrange = random.choice([(100, worlds.get_size()[0]*.25), (worlds.get_size()[0]*.25, worlds.get_size()[0]*.5), (worlds.get_size()[0]*.5, worlds.get_size()[0]*.75), (worlds.get_size()[0]*.75, worlds.get_size()[0]-100)]) _y = 100 elif _i == 2: _x = worlds.get_size()[0]-100 _y = random.choice([(100, worlds.get_size()[1]*.25), (worlds.get_size()[1]*.25, worlds.get_size()[1]*.5), (worlds.get_size()[1]*.5, worlds.get_size()[1]*.75), (worlds.get_size()[1]*.75, worlds.get_size()[1]-100)]) elif _i == 3: _x = 100 _y = random.randint(100, worlds.get_size()[1]-100) else: _x = random.randint(100, worlds.get_size()[0]-100) _y = worlds.get_size()[1]-100 _missile_turrets = int(round(10*((WAVE+1)/5.0))) _gun_turrets = int(round(10*(WAVE/5.0))) _fleas = int(round(5*(WAVE/5.0))) for i in range(_fleas): if _i == 1: _x = random.randint(100, worlds.get_size()[0]-100) _y = 100 elif _i == 2: _x = worlds.get_size()[0]-100 _y = random.randint(100, worlds.get_size()[1]-100) elif _i == 3: _x = 100 _y = random.randint(100, worlds.get_size()[1]-100) else: _x = random.randint(100, worlds.get_size()[0]-100) _y = worlds.get_size()[1]-100 _entity = ships.create_flea(x=_x, y=_y, hazard=True) _move_direction = numbers.direction_to((_x, _y,), (worlds.get_size()[0]/2, worlds.get_size()[1]/2)) entities.trigger_event(_entity, 'push', velocity=numbers.velocity(_move_direction, 20)) for i in range(_gun_turrets): if _i == 1: _x = random.randint(200, worlds.get_size()[0]-200) _y = 200 elif _i == 2: _x = worlds.get_size()[0]-200 _y = random.randint(200, worlds.get_size()[1]-200) elif _i == 3: _x = 200 _y = random.randint(200, worlds.get_size()[1]-200) else: _x = random.randint(200, worlds.get_size()[0]-200) _y = worlds.get_size()[1]-200 _entity = ships.create_gun_turret(x=_x, y=_y) _move_direction = numbers.direction_to((_x, _y,), (worlds.get_size()[0]/2, worlds.get_size()[1]/2)) entities.trigger_event(_entity, 'push', velocity=numbers.velocity(_move_direction, 20)) for i in range(_missile_turrets): if _i == 1: _x = random.randint(100, worlds.get_size()[0]-100) _y = 100 elif _i == 2: _x = worlds.get_size()[0]-100 _y = random.randint(100, worlds.get_size()[1]-100) elif _i == 3: _x = 100 _y = random.randint(100, worlds.get_size()[1]-100) else: _x = random.randint(100, worlds.get_size()[0]-100) _y = worlds.get_size()[1]-100 _entity = ships.create_missile_turret(x=_x, y=_y) _move_direction = numbers.direction_to((_x, _y,), (worlds.get_size()[0]/2, worlds.get_size()[1]/2)) entities.trigger_event(_entity, 'push', velocity=numbers.velocity(_move_direction, 20)) WAVE += 1 ANNOUNCE = True