import pygame
import sys
import math
from pygame.locals import *
pygame.init()
WHITE = (255,255,255)
BLACK = (0,0,0)
GREEN = (0,255,0)
points= (100,100)
RED = (255,0,0)
BLUE = (0,0,255)
size = width,height = 640,400
screen = pygame.display.set_mode(size)
pygame.display.set_caption("Hello!")
points= [(200,75),(300,25),(400,75),(450,25),(450,125),(400,75),(300,125)]
position = size[0] //2,size[1]//2
clock = pygame.time.Clock()
moving = False
while True:
for event in pygame.event.get():
if event.type == QUIT:
sys.exit()
if event.type == MOUSEBUTTONDOWN:
if event.button == 1:
moving = True
if event.type == MOUSEBUTTONUP:
if event.button == 1:
moving = False
if moving:
position = pygame.mouse.get_pos()
screen.fill(WHITE)
pygame.draw.rect(screen,BLACK,(50,50,150,50),0) #矩形
pygame.draw.polygon(screen,GREEN,points,0) #鱼
pygame.draw.circle(screen,RED,position,25,1) #园
pygame.draw.ellipse(screen,BLACK,(100,100,440,100),1)#椭圆
pygame.draw.ellipse(screen,BLACK,(220,50,200,200),1)#圆
pygame.draw.arc(screen,BLACK,(100,100,440,100),0,math.pi,1) #一条线
pygame.draw.aaline(screen,BLACK,(100,250),(540,300),1) #一条斜线
pygame.draw.arc(screen,BLACK,(220,50,200,200),math.pi,math.pi*2,1)
pygame.draw.circle(screen,GREEN,position,75,1)
pygame.draw.circle(screen,BLUE,position,125,1)
pygame.display.flip()
clock.tick(100)