Example #1
0
    def collides_with(self, other):
        collision_distance = (self.width / 2.0) + (other.width / 2.0)
        actual_distance = utils.distance(self.position, other.position)

        proximity = actual_distance <= collision_distance

        return proximity
Example #2
0
    def collides_with(self, other):
        collision_distance = (self.width / 2.0) + (other.width / 2.0)
        actual_distance = utils.distance(self.position, other.position)

        proximity = actual_distance <= collision_distance

        damaged = self.vulnerable and other.damaging

        return (proximity and damaged)
Example #3
0
def test_distance__y_only():
    assert utils.distance((0.0, 0.0), (0.0, 7.3)) == 7.3
Example #4
0
def test_distance__x_only():
    assert utils.distance((0.0, 0.0), (1.0, 0.0)) == 1
Example #5
0
def test_distance__diagonal():
    rounded = "{:.4f}".format(utils.distance((100.0, -3.2), (-0.750, 34.0)))
    assert rounded == '107.3983'
Example #6
0
def test_asteroids__20_no_collosions():
    suts = load.asteroids(3, (100, 100))

    for sut in suts:
        assert utils.distance(sut.position, (100, 100)) >= 100