日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 人文社科 > 生活经验 >内容正文

生活经验

python端午dragboat消消乐 美轮美奂的界面效果

發布時間:2023/11/27 生活经验 65 豆豆
生活随笔 收集整理的這篇文章主要介紹了 python端午dragboat消消乐 美轮美奂的界面效果 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

python端午,dragboat消消樂 美輪美奐的界面效果

    • 1. 效果圖
    • 2. 源碼
      • 2.1 素材準備源碼(消消樂圖、bg音樂)
      • 2.2 消消樂源碼
    • 參考

跟著大佬的步伐,消消樂倆步走~~

  1. 找素材,做消消樂圖,找bg音樂🎵,成功消除🎵,失敗的🎵;
  2. 上代碼,調試~~

1. 效果圖

原始圖:

使用數組截取得到消消樂的效果圖如下,粽子圖同理


消消樂游戲效果圖gif如下~

2. 源碼

2.1 素材準備源碼(消消樂圖、bg音樂)

import cv2
import imutils
import numpy as np
from imutils import pathsimage = cv2.imread('images/xx2.jpg')
width = image.shape[0]
print(image.shape)
image = imutils.resize(image, width=400)
cv2.imshow("origin", image)
image = image[89:, 17:]
print(image.shape)
image = image[:70, :278]
print('--: ', image.shape)
img = imutils.resize(image, width=400)
cv2.imshow("slice", img)print(image.shape[0], image.shape[1])
y = [int(j) for j in np.linspace(0, image.shape[1], 6)]
print(y)for i in range(1, 6):cv2.imshow(str(i), imutils.resize(image[0:image.shape[0], y[i-1]:y[i]], width=200))cv2.imwrite("imgs/pacer"+str(i-1)+".png",imutils.resize(image[0:image.shape[0], y[i-1]:y[i]], width=80))imagePaths = list(paths.list_images("images/"))
print('len: ', len(imagePaths))x = [imagePath for imagePath in imagePaths if (imagePath.endswith(".jpg") and imagePath.__contains__('zz'))]
print(x)
for i, imgpath in enumerate(x):print(i + 5, imgpath)cv2.imshow(str(i + 6), imutils.resize(cv2.imread(imgpath), width=200))cv2.imwrite("imgs/pacer" + str(i + 5) + ".png", imutils.resize(cv2.imread(imgpath), width=80))cv2.waitKey(0)

bg音樂及成功失敗的🎵,都選自己喜歡的mp3格式就可以

2.2 消消樂源碼

# USAGE
# python .\xxl.py
'''
Function:消消樂
'''
import os
import sysimport cfg
import pygame
from modules.game import pacerGame'''主程序'''def main():pygame.init()screen = pygame.display.set_mode(cfg.SCREENSIZE)pygame.display.set_caption('dragonboat xxl')# 加載背景音樂pygame.mixer.init()pygame.mixer.music.load(os.path.join(cfg.ROOTDIR, "res/audios/bg.mp3"))pygame.mixer.music.set_volume(0.6)pygame.mixer.music.play(-1)# 加載音效sounds = {}# sounds['mismatch'] = pygame.mixer.Sound(os.path.join(cfg.ROOTDIR, 'res/audios/badswap.wav'))sounds['mismatch'] = pygame.mixer.Sound(os.path.join(cfg.ROOTDIR, 'res/audios/badswap.mp3'))sounds['match'] = []for i in range(6):sounds['match'].append(pygame.mixer.Sound(os.path.join(cfg.ROOTDIR, 'res/audios/match%s.mp3' % i)))# sounds['match'].append(pygame.mixer.Sound(os.path.join(cfg.ROOTDIR, 'res/audios/match%s.wav' % i)))# 字體顯示font = pygame.font.Font(os.path.join(cfg.ROOTDIR, 'res/font/font.TTF'), 25)# 星星pacer_imgs = []for i in range(1, 8):pacer_imgs.append(os.path.join(cfg.ROOTDIR, 'res/imgs/pacer%s.png' % i))# 循環game = pacerGame(screen, sounds, font, pacer_imgs, cfg)while True:score = game.start()flag = False# 給出選擇,玩家選擇重玩或者退出while True:for event in pygame.event.get():if event.type == pygame.QUIT or (event.type == pygame.KEYUP and event.key == pygame.K_ESCAPE):pygame.quit()sys.exit()elif event.type == pygame.KEYUP and event.key == pygame.K_r:flag = Trueif flag:breakscreen.fill((136, 207, 236))text0 = 'Final score: %s' % scoretext1 = 'Press <R> to restart the game.'text2 = 'Press <Esc> to quit the game.'y = 150for idx, text in enumerate([text0, text1, text2]):text_render = font.render(text, 1, (85, 65, 0))rect = text_render.get_rect()if idx == 0:rect.left, rect.top = (223, y)elif idx == 1:rect.left, rect.top = (133.5, y)else:rect.left, rect.top = (126.5, y)y += 99screen.blit(text_render, rect)pygame.display.update()game.reset()'''游戲運行'''
if __name__ == '__main__':main()

參考

  • https://blog.csdn.net/weixin_42350212/article/details/117765694

總結

以上是生活随笔為你收集整理的python端午dragboat消消乐 美轮美奂的界面效果的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。