-
代码:
"""qiyiou"""
import pygame
if __name__ == '__main__':
pygame.init()
screen = pygame.display.set_mode((600,400))
screen.fill((0,0,0))
from math import pi
pygame.draw.arc(screen, (255, 255, 255), (255, 0, 90, 120), -pi*2, -pi ,2)#头
pygame.draw.line(screen, (255, 255, 255), (255, 58), (225, 200), 2)#左臂
pygame.draw.line(screen, (255, 255, 255), (345, 58), (385, 200), 2)#右臂
pygame.draw.arc(screen, (255, 255, 255), (225, 190, 10, 20), pi, pi*2, 2)#左手
pygame.draw.arc(screen, (255, 255, 255), (377, 190, 10, 20), pi, pi*2, 2)#右手
pygame.draw.line(screen, (255, 255, 255), (235, 200), (245, 260), 2)#左脚
pygame.draw.line(screen, (255, 255, 255), (245, 260), (265, 260), 2)
pygame.draw.line(screen, (255, 255, 255), (265, 260), (270, 230), 2)
pygame.draw.line(screen, (255, 255, 255), (377, 200), (365, 260), 2)#右脚
pygame.draw.line(screen, (255, 255, 255), (345, 260), (365, 260), 2)
pygame.draw.line(screen, (255, 255, 255), (345, 260), (340, 230), 2)
pygame.draw.line(screen, (255, 255, 255), (270, 230), (340, 230), 2)#底盘
# pygame.draw.arc(screen, (255, 255, 255), (282, 40, 40, 30), -pi * 2, -pi, 2)#嘴
# pygame.draw.arc(screen, (255, 255, 255), (282, 40, 40, 30), -pi, -pi*2, 2)
pygame.draw.ellipse(screen, (255, 255, 255), (282, 40, 40, 30))
pygame.draw.ellipse(screen, (0, 0, 0), (285, 55, 35, 10))
# pygame.draw.arc(screen, (0, 0, 0), (285, 52, 35, 10), -pi, -pi * 2, 0)
# pygame.draw.arc(screen, (0, 0, 0), (285, 52, 35, 5), -pi*2, -pi, 0)
pygame.draw.circle(screen,(255,255,255),(282,35),10,0)#眼睛
pygame.draw.circle(screen, (255, 255, 255), (322, 35), 10, 0)
pygame.draw.circle(screen, (0, 0, 0), (322, 35), 2, 0)
pygame.draw.circle(screen, (0, 0, 0), (282, 35), 2, 0)
pygame.draw.arc(screen, (255, 255, 255), (272, 20, 20, 10), -pi * 2, -pi, 2)#眉毛
pygame.draw.arc(screen, (255, 255, 255), (308, 20, 20, 10), -pi * 2, -pi, 2)
pygame.draw.circle(screen, (0, 0, 0), (302, 45), 5, 0)#鼻子
pygame.draw.circle(screen, (255, 0, 0), (260, 52), 15, 0)#腮
pygame.draw.circle(screen, (255, 0, 0), (340, 52), 15, 0)
pygame.draw.circle(screen, (255, 255, 255), (268, 14), 10, 1)#耳朵
pygame.draw.circle(screen, (255, 255, 255), (332, 14), 10, 1)
pygame.draw.circle(screen, (255, 255, 255), (268, 14), 4, 0)
pygame.draw.circle(screen, (255, 255, 255), (332, 14), 4, 0)
pygame.display.flip()
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
exit()
-
总结
第一次使用pygame画这种图形,其中有很多东西没有画出来,即使现在画出来的也还是有瑕疵,不过我终究会完善出来,熟练使用。这个图形对我来说,最大的难度是内部填充黑色,因为不知道如何在这种组合区域内填充,所幸的是内部填充是黑色,所以经过思考我将窗口填充黑色,用白色线条描轮廓,这样就能看出这是熊本熊。换个角度解决问题,总的来说是能解决的,不过更多的是需要学习,更完美的写出代码。以后的学习加油!