import pygame
if __name__ == '__main__':
# 初始化pygame
pygame.init()
# 创建游戏窗口
#set_mode((宽度,高度)) 单位:像素
screen = pygame.display.set_mode((800, 600))
# 设置窗口的背景颜色
screen.fill((255, 255, 255)) #(255,255,255)-> 白色
#画椭圆
#ellipse(Surface, color, Rect, width=0)
#头部
pygame.draw.ellipse(screen, (0, 0, 0), (200, 50, 130, 100), 2)
#画圆
#circle(Surface(位置), color(颜色), pos(圆心位置), radius(半径), width=0)
#眼睛
pygame.draw.circle(screen, (0, 0, 0), (235, 100), 10)
pygame.draw.circle(screen, (0, 0, 0), (295, 100), 10)
#胸前圆
pygame.draw.circle(screen, (0, 0, 0), (315, 200), 15, 2)
#画直线
#line(Surface, color, start_pos, end_pos, width=1)
pygame.draw.line(screen, (0, 0, 0), (235, 100), (295, 100), 3)
#胸前圆线
#lines(Surface(画线的位置), color(颜色), closed(是否封闭), pointlist(点的列表), width(宽度))
pygame.draw.lines(screen, (0, 0, 0), False, [(300, 200), (310, 200), (312, 195), (318, 195), (320, 200), (330, 200)], 2)
# 画曲线
# arc(Surface, color, Rect, start_angle, stop_angle, width=1)
# Rect -> (x, y, width, height)
# start_angle -> 起始角度
# stop_angle -> 终止角度
from math import pi
#上半身
pygame.draw.arc(screen, (0, 0, 0), (165, -14, 800, 600), pi/2+pi/3, pi, 2)
pygame.draw.arc(screen, (0, 0, 0), (-437, -24, 800, 600), 0, pi/6, 2)
#肚子
pygame.draw.arc(screen, (0, 0, 0), (150, 210, 230, 215), pi*3/3.6, pi/5.8, 2)
pygame.draw.arc(screen, (0, 0, 0), (150, 220, 230, 215), pi * 5 / 18, pi*13 / 18, 2)
#手臂
pygame.draw.arc(screen, (0, 0, 0), (122, 30, 700, 700), pi * 14 / 18, pi * 19 / 18, 2)
pygame.draw.arc(screen, (0, 0, 0), (-295, 20, 700, 700), -pi * 1 / 18, pi * 4 / 18, 2)
#左手
pygame.draw.arc(screen, (0, 0, 0), (126, 405, 14, 35), pi * 22 / 18, pi * 40 / 18, 2)
pygame.draw.arc(screen, (0, 0, 0), (138, 400, 40, 50), pi * 19 / 18, pi * 39 / 18, 2)
#右手
pygame.draw.arc(screen, (0, 0, 0), (385, 405, 14, 35), pi * 14 / 18, pi * 34 / 18, 2)
pygame.draw.arc(screen, (0, 0, 0), (347, 398, 40, 50), -pi * 21 / 18, pi * 2 / 18, 2)
#腿部
pygame.draw.arc(screen, (0, 0, 0), (175, 300, 90, 200), pi*17/18, pi*34/18, 2)
pygame.draw.arc(screen, (0, 0, 0), (260, 302, 90, 200), pi * 20 / 18, pi * 37 / 18, 2)
# 创建自定义字体
# Font(字体文件路径,字体大小)
font = pygame.font.Font('./aa.ttf', 50)
# 根据字体创建显示对象(文字)
surface = font.render('hello,I\'m Baymax !', True, (0, 0, 0))
# 将内容添加到窗口上(画到纸上)
screen.blit(surface, (380, 450))
# 将窗口上的内容展示出来(将画有文字的纸贴出来)
pygame.display.flip()
# 游戏循环
while True:
# 检测事件
for event in pygame.event.get():
# 检测窗口上的关闭按钮是否被点击
if event.type == pygame.QUIT:
# 退出游戏
print('关闭按钮被点击')
exit()