画圆
pygame.draw.circle(画在哪,线的颜色,圆心的坐标,半径,线宽=0(颜色全部填充))
画矩形
pygame.draw.rect(画在哪,线的颜色,矩形范围(x,y,w,h),线宽=0(颜色全部填充))
画多边形
pygame.draw.polygon(画在哪,线的颜色,多边形多个顶点坐标列表,width=0)
画椭圆
pygame.draw.ellipse(画在哪,线的颜色,矩形范围(x,y,w,h),线宽=0
画一条弧线
pygame.draw.arc(画在哪,线的颜色,矩形范围,起始弧度,终止弧度(0-2π),线宽=1)
游戏动画
import pygame
import math
pygame.init()
screen_obj = pygame.display.set_mode((600,700))
screen_obj.fill((255,255,255))
pygame.display.set_caption('游戏动画')
pygame.draw.circle(screen_obj,(0,255,0),(300,60),60)
pygame.display.flip()
circle_y = 60
num = 1
speed = 1
while 1:
num += 1
if num % 100 == 0:
pygame.draw.circle(screen_obj,(255,255,255),(300, circle_y), 60)
circle_y += speed
pygame.draw.circle(screen_obj,(0, 255, 0), (300, circle_y), 60)
if circle_y+60 == 700 :
speed = -1
elif circle_y == 60:
speed = 1
pygame.display.update()