def draw_board(game_state):
    for coord in coords.get_all_box_coords():
        if not game_state.reveal_data.is_revealed(coord):
            top_left_corner_coord = coords.top_left_coords_of_box(coord)
            pygame.draw.rect(game_state.display_surface, constants.BOX_COLOR,
                             (top_left_corner_coord.pixel_x,
                              top_left_corner_coord.pixel_y,
                              settings.BOX_SIZE,
                              settings.BOX_SIZE)
                             )
        else:
            icon = game_state.board[coord.box_x][coord.box_y]
            if icon[0] == constants.SQUARE:
                shape_drawer = shape.Square(icon[1], coord,
                                            game_state.display_surface)
                shape_drawer.draw()
Beispiel #2
0
import shape

#print(dir(shape))

square = shape.Square(2.0)
s_area = square.Area()
print("Square area: {0:f}".format(s_area))

circle = shape.Circle(2.0)
c_area = circle.Area()
c_list = circle.GetList()
print("Circle area: {0:s}".format(str(c_list)))


Beispiel #3
0
def test_shape_Circle_is_not_equal_to_square():
    c = shape.Circle(2)
    s = shape.Square(2)
    assert not c.is_equal(s)
Beispiel #4
0
import shape as sh

# 建立Circle、Rectangle和Triangle類別的物件
c = sh.Circle(10)
r = sh.Rectangle(5, 2)
t = sh.Triangle(8, 3)
s = sh.Square(6)

# 把物件加入Tuple資料組
shapes = c, r, t, s

# 用For迴圈顯示每一個物件的資訊和面積
for s in shapes:
    s.show_shape_info()
    print('面積:' + str(s.get_area()))
import shape

print("Hello")
s1 = shape.Square(5)
s2 = shape.Square(4)

area = s1.getArea()

s3 = shape.Square()

print(s3)
Beispiel #6
0
def main():
	s = shape.Square(5)	
	print(s.area())

	r = shape.Rectangle(5, 10)
	print(r.perimeter())