国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > Python > 正文

python中pygame模塊用法實例

2020-02-23 06:04:08
字體:
來源:轉載
供稿:網友

本文實例講述了python中pygame模塊用法,分享給大家供大家參考。具體方法如下:

import pygame, sys from pygame.locals import *  #set up pygame pygame.init()  windowSurface = pygame.display.set_mode((500, 400), 0, 32) pygame.display.set_caption("hello, world")  BLACK = (0, 0, 0) WHITE = (255, 255, 255) RED = (255, 0, 0) GREEN = (0, 255, 0) BLUE = (0, 0, 255)  basicFont = pygame.font.SysFont(None, 48) text = basicFont.render("Hello ,world", True, WHITE, BLUE) textRect = text.get_rect()  textRect.centerx = windowSurface.get_rect().centerx textRect.centery = windowSurface.get_rect().centery  windowSurface.fill(WHITE)  pygame.draw.polygon(windowSurface, GREEN, ((146, 0),  (291, 106), (236, 277), (56, 277), (0, 106)))   pygame.draw.line(windowSurface, BLUE, (60, 60), (120,  60), 4)  pygame.draw.line(windowSurface, BLUE, (120, 60), (60,  120))  pygame.draw.line(windowSurface, BLUE, (60, 120), (120,  120), 4)  pygame.draw.circle(windowSurface, BLUE, (300, 50), 20, 0)  pygame.draw.ellipse(windowSurface, RED, (300, 250, 40,  80), 1)   pygame.draw.rect(windowSurface, RED, (textRect.left - 20,  textRect.top - 20, textRect.width + 40, textRect.height + 40))  pixArray = pygame.PixelArray(windowSurface)  pixArray[480][380] = BLACK  del pixArray   windowSurface.blit(text, textRect)   pygame.display.update()  while True:    for event in pygame.event.get():      if event.type == QUIT:        pygame.quit()        sys.exit()  

運行后打出的圖片如下:

希望本文所述對大家的Python程序設計有所幫助。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 苍山县| 长丰县| 大石桥市| 台东市| 丽江市| 龙里县| 新沂市| 尼勒克县| 咸丰县| 左云县| 陵水| 北安市| 江门市| 宁陵县| 九江市| 集贤县| 襄垣县| 冷水江市| 云南省| 雷州市| 阿克苏市| 江达县| 上栗县| 祁东县| 翁牛特旗| 子长县| 饶河县| 公主岭市| 泸水县| 杭锦旗| 静安区| 太保市| 山西省| 临海市| 沛县| 大化| 东港市| 田林县| 松原市| 邹城市| 游戏|