《Python游戏编程入门》(一)

一,画椭圆:

使用pygame.draw.ellipse(Surface, color, Rect, width=0)绘制椭圆其中参数Rect是椭圆的外切矩形的坐标其长宽是椭圆的轴长。椭圆线宽参数width=0,或省略时,绘制的椭圆是被设定的颜色填充。http://www.shfdjk.com

完整代码

import pygame

import sys

from pygame.locals import *

pygame.init()

screen=pygame.display.set_mode((600,500))

pygame.display.set_caption('Drawing Ellipse')

x=300

y=250

while True:

    for event in pygame.event.get():

        if event.type==QUIT:

            sys.exit()

    screen.fill((0,0,200))

    #draw a ellipse

    color=255,0,255

    width=1

    position=250,150,300,200

    pygame.draw.ellipse(screen,color,position,width)

    pygame.display.update()

猜你喜欢

转载自blog.csdn.net/moyouyou123/article/details/80565732