import sys
import pygame
from pygame.locals import *
white =255,255,255;
blue=0,0,200
pygame.init()
screen=pygame.display.set_mode((600,500))
myfont=pygame.font.Font(None,60)
textImage=myfont.render("Hello Pygame",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))
pygame.display.update()
2.绘制圆形
import sys
import pygame
from pygame.locals import *
white =255,255,255;
blue=0,0,200
pygame.init()
screen=pygame.display.set_mode((600,500))
pygame.display.set_caption("Drawing Circles")
myfont=pygame.font.Font(None,60)
textImage=myfont.render("Hello Pygame",True,white)
while True:
for event in pygame.event.get():
if event.type in (QUIT,KEYDOWN):
sys.exit()
screen.fill((0,0,200))
#draw a circle
color =255,255,0
posotion=300,250
radius=100
width=10
pygame.draw.circle(screen,color,posotion,radius,width)
pygame.display.update()