Beispiel #1
0
def test_collision_detection_launch_inside_wall():
    # extracted from a real crash
    dodo = Dodo(FakeGame(FakeMap(ground_level=710, wall_x=720)))
    dodo.x = 721.0
    dodo.y = 495.0
    dodo.dx = 50.0
    dodo.dy = 50.0
    dodo.update(1.0)
    assert_equals(dodo.x, 721.0)
    assert_equals(dodo.y, 495.0)
    assert_false(dodo.is_alive)
    assert_equals(dodo.dx, 0)
    assert_equals(dodo.dy, 0)
Beispiel #2
0
def test_collision_detection_4():
    #     +-------
    #     | *
    #     |/
    #     |
    #    /|
    #   * |
    # ----+ ground 
    dodo = Dodo(FakeGame(FakeMap(ground_level=200, wall_x=40)))
    dodo.x = 20.0
    dodo.y = 30.0
    dodo.dx = 40.0
    dodo.dy = 50.0
    dodo.update(1.0)
    assert_equals((dodo.x, dodo.y), (40.0, 55))
    assert_false(dodo.is_alive)
    assert_equals(dodo.dx, 0)
    assert_equals(dodo.dy, 0)
Beispiel #3
0
def test_collision_detection_3():
    # air
    #   *
    #    \+-------
    #     |
    #     |\
    #     | *
    # ----+ ground 
    dodo = Dodo(FakeGame(FakeMap(ground_level=100, wall_x=40)))
    dodo.x = 20.0
    dodo.y = 120.0
    dodo.dx = 40.0
    dodo.dy = -50.0
    dodo.update(1.0)
    assert_equals(dodo.x, 40.0)
    assert_equals(dodo.y, 95.0)
    assert_false(dodo.is_alive)
    assert_equals(dodo.dx, 0)
    assert_equals(dodo.dy, 0)
Beispiel #4
0
def test_collision_detection_2():
    # air
    #   *
    #    \
    #    +------
    #    | \
    #    |  *
    #    |ground
    dodo = Dodo(FakeGame(FakeMap(ground_level=100, wall_x=22)))
    dodo.x = 20.0
    dodo.y = 120.0
    dodo.dx = 10.0
    dodo.dy = -50.0
    dodo.update(1.0)
    assert_equals(dodo.x, 24.0)
    assert_equals(dodo.y, 100.0)
    assert_true(dodo.is_alive)
    assert_equals(dodo.dx, 0)
    assert_equals(dodo.dy, 0)