コード例 #1
0
        y_vector_bbox.height=bbox.height

    # --- Game logic should go here
    # --- Drawing code should go here
    # First, clear the screen to white. Don't put other drawing commands
    # above this, or they will be erased with this command.
#    surf.fill(RED)

    for i in range(0, 13):
        for j in range(0,10):
            if i == 0 or i == 12 or j == 0 or j == 9:
                tiles.blit([0,0,16,16], i*16, j*16, surf)

                tile_bbox.__init__(i*16, j*16, 16, 16)

                distance_x=distance_until_rectangles_intersect(x_vector_bbox,player.delta_x_vector,tile_bbox)
                if distance_x is not None:
                    if player.delta_x_vector.x < 0:
                        player.delta_position.x = -distance_x
                    else:
                        player.delta_position.x = distance_x

                distance_y=distance_until_rectangles_intersect(y_vector_bbox,player.delta_y_vector,tile_bbox)
                if distance_y is not None:
                    if player.delta_y_vector.y < 0:
                        player.delta_position.y=-distance_y
                    else:
                        player.delta_position.y=distance_y

            else:
                tiles.blit([16,0,16,16], i*16, j*16, surf)
コード例 #2
0
    def test_moving_rectangles_dont_intersect(self):
        r1=Rect(0,0,3,3)
        r2=Rect(15,5,10,10)
        v=Point(1,0)

        self.assertEquals(distance_until_rectangles_intersect(r1,v,r2),None)
コード例 #3
0
    def test_moving_rectangles_dont_intersect(self):
        r1 = Rect(0, 0, 3, 3)
        r2 = Rect(15, 5, 10, 10)
        v = Point(1, 0)

        self.assertEquals(distance_until_rectangles_intersect(r1, v, r2), None)
コード例 #4
0
    def test_distance_until_rectangles_intersect(self):
        r1=Rect(0,0,10,10)
        r2=Rect(15,5,10,10)
        v=Point(10,0)

        self.assertEquals(distance_until_rectangles_intersect(r1,v,r2),5)
コード例 #5
0
    def test_distance_until_rectangles_intersect(self):
        r1 = Rect(0, 0, 10, 10)
        r2 = Rect(15, 5, 10, 10)
        v = Point(10, 0)

        self.assertEquals(distance_until_rectangles_intersect(r1, v, r2), 5)