目录
入门
画一个奥运五环
import pygame
import sys
from pygame.locals import *
pygame.init()
screen = pygame.display.set_mode((600, 500))
# None 使用默认字体 60 是字体大小
myfont = pygame.font.Font(None, 60)
white = 255, 255, 255
blue = 255, 0, 0
textImage = myfont.render("Hello World!", True, white)
while True:
for event in pygame.event.get():
if event.type in (QUIT, KEYDOWN):
sys.exit()
screen.fill(blue)
screen.blit(textImage, (100, 100))
# 绘制圆
color_blue = 41, 167, 225
color_black = 35,24,22
color_green = 35,172,56
color_yellow = 255,241,0
color_white = 255,255,255
position_1 = 100, 255
position_2 = 210, 255
position_3 = 320, 255
position_4 = 155, 305
position_5 = 265, 305
radius = 50
width = 5
pygame.draw.circle(screen, color_blue, position_1, radius, width)
pygame.draw.circle(screen, color_black, position_2, radius, width)
pygame.draw.circle(screen, color_green, position_3, radius, width)
pygame.draw.circle(screen, color_yellow, position_4, radius, width)
pygame.draw.circle(screen, color_white, position_5, radius, width)
pygame.display.update()