pygame

出自Local Chinese Wikipedia
imported>Mhss2026年2月23日 (一) 05:09的修訂 top
(差異) ←上個修訂 | 最新修訂 (差異) | 下個修訂→ (差異)
跳至導覽 跳至搜尋

頁面Module:Message box/mbox.css沒有內容。頁面Template:Ambox/style.css沒有內容。

package.lua第80行Lua錯誤:module 'Module:CGroup/core' not found

頁面Module:Infobox/styles.css沒有內容。

Pygame
File:Pygame logo.svg
腳本錯誤:沒有「InfoboxImageVariant」這個模塊。
開發者pygame Community
首次發布2000年10月30日,​25年前​(2000-10-30[1][2]
當前版本2.6.1(2024年8月30日,​22個月前​(2024-08-30[3]
操作系統跨平台
類型API
許可協議GNU寬通用公共許可證
網站http://www.pygame.org
腳本錯誤:沒有「Template wrapper」這個模塊。

pygame[4]跨平台Python模塊組,專為電子遊戲設計。包含圖像、聲音。建立在SDL基礎上,允許實時電子遊戲研發而無需被低階語言,如C語言或是更低階的組合語言束縛。基於這樣一個設想,所有需要的遊戲功能和理念都(主要是圖像方面)完全簡化位遊戲邏輯本身,所有的資源結構都可以由高級語言提供,如Python

pygame原為代替突然停止的pySDL[5]

pygame在Android[編輯]

pygame應用程式能夠在Android手機和平板執行,採用pygame對於Android的子集(pgs4a)。[6] 支援Android的聲音,振動,鍵盤和加速。[7]但缺點是沒有辦法在iOS上執行pygame應用程式。其它pgs4a的主要限制是缺乏對於多點觸控的支援, 這使得雙指縮放,以及旋轉無法使用。另一個pygame在Android子集的替代方案是Kivy[8]它包含了多點觸控及iOS的支援。

例子[編輯]

這段代碼假設在它運行的同一個目錄中有一個名為 ball.png 的(球的)圖像,它將在窗口中快速移動。[9]


import sys, pygame
pygame.init()
size = width, height = 320, 240
speed = [2, 2]
black = 0, 0, 0
screen = pygame.display.set_mode(size)
ball = pygame.image.load("ball.png")
ballrect = ball.get_rect()
while 1:
    for event in pygame.event.get():
        if event.type == pygame.QUIT: sys.exit()
    ballrect = ballrect.move(speed)
    if ballrect.left < 0 or ballrect.right > width:
        speed[0] = -speed[0]
    if ballrect.top < 0 or ballrect.bottom > height:
        speed[1] = -speed[1]
    screen.fill(black)
    screen.blit(ball, ballrect)
    pygame.display.flip()

其他[編輯]

package.lua第80行Lua錯誤:module 'Module:Portal/images/chinese' not found package.lua第80行Lua錯誤:module 'Module:Portal/images/chinese' not found 展示:

  • Pyweek,遊戲製作競賽,時間限制在7天內
  • Ludum DareLD48 遊戲製作競賽,時間限制在48小時內

2D引擎和庫:

社群[編輯]

有定期的競賽,叫做PyWeek. 使用Python寫出遊戲(通常但不一定使用pygame)。[10][11][12]社群已經創造了許多Pygame的教學。[13][14][15][16][17][18]

參考[編輯]

  1. package.lua第80行Lua錯誤:module 'Module:Citation/CS1/Identifiers' not found
  2. package.lua第80行Lua錯誤:module 'Module:Citation/CS1/Identifiers' not found
  3. package.lua第80行Lua錯誤:module 'Module:Citation/CS1/Identifiers' not found
  4. package.lua第80行Lua錯誤:module 'Module:Citation/CS1/Identifiers' not found
  5. package.lua第80行Lua錯誤:module 'Module:Citation/CS1/Identifiers' not found
  6. package.lua第80行Lua錯誤:module 'Module:Citation/CS1/Identifiers' not found
  7. package.lua第80行Lua錯誤:module 'Module:Citation/CS1/Identifiers' not found
  8. package.lua第80行Lua錯誤:module 'Module:Citation/CS1/Identifiers' not found
  9. package.lua第80行Lua錯誤:module 'Module:Citation/CS1/Identifiers' not found
  10. package.lua第80行Lua錯誤:module 'Module:Citation/CS1/Identifiers' not found
  11. package.lua第80行Lua錯誤:module 'Module:Citation/CS1/Identifiers' not found
  12. package.lua第80行Lua錯誤:module 'Module:Citation/CS1/Identifiers' not found
  13. package.lua第80行Lua錯誤:module 'Module:Citation/CS1/Identifiers' not found
  14. package.lua第80行Lua錯誤:module 'Module:Citation/CS1/Identifiers' not found
  15. package.lua第80行Lua錯誤:module 'Module:Citation/CS1/Identifiers' not found
  16. package.lua第80行Lua錯誤:module 'Module:Citation/CS1/Identifiers' not found
  17. package.lua第80行Lua錯誤:module 'Module:Citation/CS1/Identifiers' not found
  18. package.lua第80行Lua錯誤:module 'Module:Citation/CS1/Identifiers' not found

鏈接[編輯]

Template:遊戲引擎