Exemplo n.º 1
0
def test_compute_player_motion_mount_and_active_floor():
    elevator = Movable(
        type=EntityDBEntry(id=EntityType.ACTIVEFLOOR_ELEVATOR),
        position_x=0.5,
        position_y=0.7,
        velocity_x=-0.1,
        velocity_y=-0.3,
    )
    poly_elevator = PolyPointer(101, elevator, MemContext())
    # Turkey on an elevator
    mount = Mount(
        type=EntityDBEntry(id=EntityType.MOUNT_TURKEY),
        position_x=18,
        position_y=13,
        velocity_x=-2,
        velocity_y=-7,
        overlay=poly_elevator,
    )
    poly_mount = PolyPointer(102, mount, MemContext())
    player = Player(position_x=5,
                    position_y=7,
                    velocity_x=-1,
                    velocity_y=-3,
                    overlay=poly_mount)
    expected_motion = PlayerMotion(position_x=18.5,
                                   position_y=13.7,
                                   velocity_x=-2.1,
                                   velocity_y=-7.3)
    run_state = RunState()
    assert run_state.compute_player_motion(player) == expected_motion
Exemplo n.º 2
0
def test_compute_player_motion_wo_overlay():
    player = Player(position_x=5, position_y=7, velocity_x=-1, velocity_y=-3)
    expected_motion = PlayerMotion(position_x=5,
                                   position_y=7,
                                   velocity_x=-1,
                                   velocity_y=-3)
    run_state = RunState()
    assert run_state.compute_player_motion(player) == expected_motion
Exemplo n.º 3
0
def test_compute_player_motion_mount():
    mount = Mount(
        type=EntityDBEntry(id=EntityType.MOUNT_TURKEY),
        position_x=18,
        position_y=13,
        velocity_x=-2,
        velocity_y=-7,
    )
    poly_mount = PolyPointer(101, mount, MemContext())
    player = Player(position_x=5,
                    position_y=7,
                    velocity_x=-1,
                    velocity_y=-3,
                    overlay=poly_mount)
    expected_motion = PlayerMotion(position_x=18,
                                   position_y=13,
                                   velocity_x=-2,
                                   velocity_y=-7)
    run_state = RunState()
    assert run_state.compute_player_motion(player) == expected_motion
Exemplo n.º 4
0
def test_compute_player_motion_active_floor():
    elevator = Movable(
        type=EntityDBEntry(id=EntityType.ACTIVEFLOOR_ELEVATOR),
        position_x=0.5,
        position_y=0.7,
        velocity_x=-0.1,
        velocity_y=-0.3,
    )
    poly_elevator = PolyPointer(101, elevator, MemContext())
    player = Player(position_x=5,
                    position_y=7,
                    velocity_x=-1,
                    velocity_y=-3,
                    overlay=poly_elevator)
    expected_motion = PlayerMotion(position_x=5.5,
                                   position_y=7.7,
                                   velocity_x=-1.1,
                                   velocity_y=-3.3)
    run_state = RunState()
    assert run_state.compute_player_motion(player) == expected_motion