コード例 #1
0
ファイル: enemy_ai.py プロジェクト: ghostonline/ld24
def process_events():
    dead_enemies = enemies.intersection(health.killed)
    for entity_id in dead_enemies:
        score.award(entity_id)
        position = spatial.get_position(entity_id)
        explosions.create(position)
        manager.destroy_entity(entity_id)
コード例 #2
0
ファイル: invader_ai.py プロジェクト: ghostonline/ld24
def update(dt):
    destroy_me = []
    for entity_id, state in enemies.iteritems():
        position = spatial.get_position(entity_id)
        direction = state.direction
        if state.state == STATE_HORIZONTAL:
            relevant_axis = position[0]
            relevant_movement = state.horizontal_movement
            move_direction = [direction, 0]
            next_state = STATE_VERTICAL
            next_nextdirection = direction * -1
        elif state.state == STATE_VERTICAL:
            relevant_axis = position[1]
            relevant_movement = state.vertical_movement
            move_direction = [0, direction]
            next_state = STATE_HORIZONTAL
            next_nextdirection = -1

        target = state.target
        if target is None:
            target = relevant_axis + relevant_movement * direction

        distance = (target - relevant_axis) * direction
        jetengine.move(entity_id, move_direction)
        if distance < 0:
            target = None
            state.state = next_state
            state.next_direction, state.direction = next_nextdirection, state.next_direction
            if position[1] < DESTROY_THRESHOLD_Y:
                destroy_me.append(entity_id)

        state.target = target

    for entity_id in destroy_me:
        manager.destroy_entity(entity_id)
コード例 #3
0
ファイル: evoseed.py プロジェクト: ghostonline/ld24
def update(dt):
    global collected, collected_change
    for entity_id, state in evoseeds.iteritems():
        max_health = state.max_health
        current_health = health.get_health(entity_id)
        if current_health > max_health:
            continue

        position = spatial.get_position_vec(entity_id)
        timeout = state.timeout - dt
        if timeout < 0:
            explosions.create_within_radius(position, state.radius, big=False)
            timeout = state.explode_timeout
        state.timeout = timeout

        nearest_collector, collector_position, collector_distance = spatial.nearest(
            entity_id, [collector_id], threshold=DEFAULT_COLLECTOR_THRESHOLD)
        if nearest_collector:
            pull_strength = 1 - collector_distance / DEFAULT_COLLECTOR_THRESHOLD
            drift_direction = (collector_position - position).normalized()
            drift = drift_direction * pull_strength * DRIFT_SPEED * dt
            spatial.move_vec(entity_id, drift)

    for entity_id, recipient_id in collect_events:
        addition = health.get_health(entity_id)
        health.heal(recipient_id, addition)
        collected += 1
        collected_change = True
        manager.destroy_entity(entity_id)
コード例 #4
0
ファイル: missile_ai.py プロジェクト: ghostonline/ld24
def process_events():
    missile_ids = set(missiles)
    left_world = missile_ids.intersection(collider.world_events)
    for entity_id in left_world:
        manager.destroy_entity(entity_id)

    struck_target = missile_ids.intersection(collider.collide_events)
    for entity_id in struck_target:
        if entity_id not in missiles:
            continue
        target_ids = collider.collide_events_data[entity_id]
        owner_id = missiles[entity_id][1]
        target_ids = [id_ for id_ in target_ids if id_ != owner_id]
        if target_ids:
            position = spatial.get_position(entity_id)
            spawn_missilesplash(position)
            manager.destroy_entity(entity_id)
コード例 #5
0
ファイル: kamikaze_ai.py プロジェクト: ghostonline/ld24
def process_events():
    enemy_ids = set(enemies)
    left_world = enemy_ids.intersection(collider.world_events)
    for entity_id in left_world:
        state = enemies[entity_id]
        amount = state.attempts
        if amount:
            state.state = IDLE
        else:
            score.award(entity_id)
            manager.destroy_entity(entity_id)
        state.attempts = amount - 1

    player_hit = enemy_ids.intersection(collider.collide_events)
    for entity_id in player_hit:
        health.apply_damage(player.player_id, DAMAGE)
        position = spatial.get_position(entity_id)
        explosions.create(position, big=False)
        manager.destroy_entity(entity_id)
コード例 #6
0
ファイル: bullet_ai.py プロジェクト: ghostonline/ld24
def process_events():
    bullet_ids = set(bullets)
    left_world = bullet_ids.intersection(collider.world_events)
    for entity_id in left_world:
        manager.destroy_entity(entity_id)

    global hit, hit_data
    hit = set()
    hit_data = collections.Counter()
    struck_target = bullet_ids.intersection(collider.collide_events)
    for entity_id in struck_target:
        if entity_id not in bullets:
            continue
        target_ids = collider.collide_events_data[entity_id]
        owner_id = bullets[entity_id][1]
        target_ids = [id_ for id_ in target_ids if id_ != owner_id]
        if target_ids:
            map(hit.add, target_ids)
            hit_data.update(target_ids)
            position = spatial.get_position(entity_id)
            explosions.create(position, big=False)
            manager.destroy_entity(entity_id)
コード例 #7
0
ファイル: wave.py プロジェクト: ghostonline/ld24
def wave_01():
    armada = entityid.create()
    global level
    while True:

        level_spawner = spawners.generate_enemies(level)
        manager.create_entity(armada, level_spawner)

        yield lambda: spawner.spawn_count(armada) > level - 1

        manager.destroy_entity(armada)

        yield lambda: not counter.get_count()

        level_spawner = spawners.generate_kamikaze(level)
        manager.create_entity(armada, level_spawner)

        yield lambda: spawner.spawn_count(armada) > level - 1

        manager.destroy_entity(armada)

        yield lambda: not counter.get_count()

        level += 1
コード例 #8
0
ファイル: aoe.py プロジェクト: ghostonline/ld24
def update(dt):
    for entity_id, target_ids in hit.iteritems():
        func, data = aoe_effects[entity_id]
        func(target_ids, data)
        manager.destroy_entity(entity_id)
コード例 #9
0
ファイル: animation_ai.py プロジェクト: ghostonline/ld24
def update(dt):
    finished = animations.intersection(render.finished)
    for entity_id in finished:
        manager.destroy_entity(entity_id)