"""刮刮樂趣味小游戲,這是一個有趣的小游戲,把別人的相片給刮出來,單擊左鍵刮圖,右鍵換下一張圖片"""
__author__ = "朱建澤"
__date__ = "2019/12/22"
import os
import pygame
from pygame.locals import *
from random import choice
def isimage(image):
"""通過判斷擴展名來略微判斷一個檔案是否是影像,只支持串列中的影像"""
ext = os.path.splitext(image)[-1]
if ext.lower() in [".gif",".jpg",".png",".jpeg",".bmp"]:
return True
else:
return False
running = True
size = width,height= 800,600
WHITE = (255,255,255,27)
pygame.init() # 初始化pygame模塊
screen = pygame.display.set_mode(size) # 建立顯示螢屏
pygame.display.set_caption("刮刮樂刮圖趣味小游戲_作者:朱建澤")
path = os.getcwd() + os.sep + "圖片"
photos = [ pygame.image.load(path + os.sep + image) for image in os.listdir(path) if isimage(image)]
amounts = len(photos)
index = 0
sur = pygame.Surface(size).convert_alpha() # 全是0,表現為黑色,(0, 0, 0, 255)
while running:
event = pygame.event.wait()
if event.type == QUIT:running = False
pass
if m_middle:running = False # 按中鍵退出回圈
screen.blit(photos[index],(0,0)) # 相當于背景圖
screen.blit(sur,(0,0))
pygame.display.update()
pygame.quit()
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/22290.html
標籤:其它游戲引擎
上一篇:unity的問題
下一篇:Unity3d 打包APK出下如下錯誤 CommandInvokationFailure: Failed to build apk.
