所有打的小彩点点最终会组成一个圆形的pygame小程序。
以下是部分代码预览:
""" 本程序使用python的pygame模块打彩色的圆点组成一个圆形。 """ __author__ == "李兴球" __date__ == "2018年7月" import pygame from pygame.locals import * import math import colorsys from random import randint pygame.init() screenWidth,screenHeight=480,360 screenCenterx,screenCentery = screenWidth//2 -1 ,screenHeight//2 - 1 screen = pygame.display.set_mode((screenWidth,screenHeight)) pygame.display.set_caption("pygame打彩点实验之圆形_作者:李兴球") class Pen(): def __init__(self,radius,color,thickness): self.color = color #笔颜色 self.thickness = thickness #笔迹宽度 self.x = screenCenterx self.y = screenCentery self.radius =radius pass def main(): pen = Pen(120,(255,0,0),2) clock = pygame.time.Clock() 运行中 = True while 运行中: for event in pygame.event.get(): if event.type==QUIT:运行中=False pen.setxy() pen.coloradd() pygame.display.update() clock.tick(30) pygame.quit() if __name__=="__main__": main()
如需要查看完整代码,请
需要浏览更多吗?
成为会员后,登陆才能继续浏览!联系微信scratch8即可办理会员。
(会员专属:能浏览所有文章,下载所有带链接的Python资源。)
发表评论