程式開始
一、基本使用
1、創建一個游戲視窗出來
代碼如下:
# coding:utf8 import pygame import sys # 初始化pygame pygame.init() # 變數定義 size = width, height = 600, 400 bg = (255, 255, 255) # 創建一個游戲視窗 screen = pygame.display.set_mode(size) # 游戲標題 pygame.display.set_caption("游戲title") # 視窗想要長期存在,必須一個死回圈 while True: # 遍歷事件,當事件等于退出時,程式結束 for event in pygame.event.get(): if event.type == pygame.QUIT: sys.exit() # 填充背景 screen.fill(bg) # 更新界面 pygame.display.flip()
效果如下:

被我刷白了,看不出效果,
讀書和健身總有一個在路上
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/149803.html
標籤:Python
下一篇:Pygame的影像移動
