Exemplo n.º 1
0
def collision_handler(state, collisions_list):
        for entity_name_1, entity_name_2 in collisions_list:
                if entity_name_1 == ENT_MAN:
                        if entity_name_2 == ENT_SHOT:
                                pass
                        elif entity_name_2 == ENT_GHOST:
                                entities.undo_last_move(state, ENT_MAN)
                                if not movers.get_active(state, ENT_GHOST)[0] == "wait":
                                        wait_mover.add(state, ENT_GHOST, 1.0, prepend=True)
                                        incr_health(state, -80)
                                        if get_health(state) <= 0:
                                                do_game_over(state)
                                else:
                                        entities.undo_last_move(state, ENT_GHOST)
                        elif entity_name_2[0:len(ENT_PREFIX_COINS)] == ENT_PREFIX_COINS:
                                incr_score(state, 10)
                                destroy_mover.add(state, entity_name_2, do_replace=True)
                        else:
                                entities.undo_last_move(state, entity_name_1)
                elif entity_name_1 == ENT_SHOT:
                        if entity_name_2[0:len(ENT_PREFIX_COINS)] == ENT_PREFIX_COINS:
                                pass
                        elif entity_name_2 == ENT_GHOST:
                                do_ghost_boom(state, entities.get_pos(state, ENT_GHOST))
                                destroy_mover.add(state, ENT_GHOST, do_replace=True)
                                do_shot_boom(state, entities.get_pos(state, ENT_SHOT))
                                destroy_mover.add(state, ENT_SHOT, do_replace=True)
                        else:
                                do_shot_boom(state, entities.get_pos(state, ENT_SHOT))
                                destroy_mover.add(state, ENT_SHOT, do_replace=True)
Exemplo n.º 2
0
def run(state, entity_name, mover, frame_time_delta, movers_to_delete):
    """
        TODO
        """
    speed = mover[IDX_FLIPPER_MOVER_SPEED]
    offset_pos = mover[IDX_FLIPPER_MOVER_OFFSET_POS]
    centre_pos = mover[IDX_FLIPPER_MOVER_CENTRE_POS]
    angle = mover[IDX_FLIPPER_MOVER_ANGLE]

    rotated_centre_x, rotated_centre_y = math_2d.rotated_point(
        offset_pos, centre_pos, angle)

    entities.set_pos(state, entity_name, rotated_centre_x, rotated_centre_y,
                     angle)

    collision_result = collisions.run(state, entity_name)
    if collision_result:
        entities.undo_last_move(state, entity_name)
        collision_handler(*collision_result)
    else:
        angle += (speed * frame_time_delta) / 1000.0
        angle = math.fmod(angle, 360.0)
        mover[IDX_FLIPPER_MOVER_ANGLE] = angle
Exemplo n.º 3
0
def run(state, entity_name, mover, frame_time_delta, movers_to_delete):
        """
        TODO
        """
        speed = mover[IDX_FLIPPER_MOVER_SPEED]
        offset_pos = mover[IDX_FLIPPER_MOVER_OFFSET_POS]
        centre_pos = mover[IDX_FLIPPER_MOVER_CENTRE_POS]
        angle = mover[IDX_FLIPPER_MOVER_ANGLE]

        rotated_centre_x,rotated_centre_y = math_2d.rotated_point(offset_pos,
                                                                      centre_pos,
                                                                      angle)

        entities.set_pos(state, entity_name, rotated_centre_x, rotated_centre_y, angle)

        collision_result = collisions.run(state, entity_name)
        if collision_result:
                entities.undo_last_move(state, entity_name)
                collision_handler(*collision_result)
        else:
                angle += (speed * frame_time_delta) / 1000.0
                angle = math.fmod(angle, 360.0)
                mover[IDX_FLIPPER_MOVER_ANGLE] = angle