最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Python實(shí)現(xiàn)敲擊木魚積累功德小項(xiàng)目

 更新時間:2022年11月15日 15:43:03   作者:DY.memory  
最近大家都很流行用手機(jī)敲擊電子木魚積累功德,這在很多短視頻中也常常見到。本文將用Python實(shí)現(xiàn)這一效果,感興趣的小伙伴可以了解一下

前言:前幾天上課閑著沒事寫了一個python敲擊木魚積累功德的小項(xiàng)目,當(dāng)時純粹就是寫著玩,回顧一下鼠標(biāo)事件的東西還記不記得,發(fā)現(xiàn)這個博客的點(diǎn)贊和收藏量還挺高的,我當(dāng)時也沒有把它當(dāng)回事,后面也有很多人問怎么實(shí)現(xiàn)的,想讓我再添加一些其他功能!

隨著點(diǎn)贊量和關(guān)注量不斷增高,我又重新看了一下博客,感覺過于簡單了,實(shí)在不配當(dāng)當(dāng)時python熱榜的第一,所以我又把代碼給稍微大改了一下,在原來總體實(shí)現(xiàn)的基礎(chǔ)上添加了如下功能!

我們先看原來的效果:

1:實(shí)現(xiàn)了點(diǎn)擊鼠標(biāo)會彈出切換功德+1的surface界面,鼠標(biāo)松開回復(fù)原先界面!

2:隨著鼠標(biāo)按鍵的按下同時也會伴隨木魚敲擊的空靈的聲音!

本次更新之后的功能有:

1:點(diǎn)擊鼠標(biāo)按鍵會出現(xiàn)功德+1和累計(jì)敲擊多少次,積累了多少功德的新畫面

2:優(yōu)化了聲音的play,降噪處理!

3:增加較強(qiáng)的互動性能,在不斷的積累功德的過程中,會不定時隨機(jī)出現(xiàn)意想不到的的互動效果,極大程度增加了該程序的趣味性!

ps:下次更新可能會在半個月后了,屆時會使用tk的模塊添加登錄注冊,以及網(wǎng)絡(luò)編程的使用用戶功德的統(tǒng)計(jì)排行榜!最近期末,還請諒解!

好了,話不多說,直接上代碼:

import pygame
from locale import *
pygame.init()
pygame.mixer.init()
screen=pygame.display.set_mode((700,500))
pygame.display.set_caption("木魚功德")

img1=pygame.image.load("images/muyuluck1.jpg")
# img2=pygame.image.load("images/muyulucky2.png")
img2=pygame.image.load("images/zan.jpg")
img3=pygame.image.load("images/qw.png")
rect1=img1.get_rect()

muyulucky = pygame.mixer.Sound('sound/muyu.WAV')
muyulucky.set_volume(0.4)
if pygame.mouse.get_focused():
            # 獲取光標(biāo)位置,2個值
    ball_x, ball_y = pygame.mouse.get_pos()
screen.blit(img1, (-180, -100))
count=0
f = pygame.font.SysFont('華文楷體',50)
f1 = pygame.font.SysFont('華文楷體',30)
# 生成文本信息,第一個參數(shù)文本內(nèi)容;第二個參數(shù),字體是否平滑;
# 第三個參數(shù),RGB模式的字體顏色;第四個參數(shù),RGB模式字體背景顏色;
# text = f.render("功德+1",True,(255,0,0),(0,0,0))
# text1=f1.render("今日積累功德"+str(count)+"次",True,(255,0,0),(0,0,0))
#獲得顯示對象的rect區(qū)域坐標(biāo)
# textRect =text.get_rect()
# text1Rect =text1.get_rect()
# 設(shè)置顯示對象居中
# textRect.topleft = (30,30)
# text1Rect.topleft = (450,30)
flag = False
while True:
    for event in pygame.event.get():
        if pygame.Rect.collidepoint(rect1, (ball_x, ball_y)) and event.type==pygame.MOUSEBUTTONDOWN:
            muyulucky.play()
            flag=True
            count = count + 1
            text = f.render("功德+1", True, (255, 0, 0), (0, 0, 0))
            textRect = text.get_rect()
            textRect.topleft = (30, 30)
            text1 = f1.render("今日積累功德" + str(count) + "次", True, (255, 0, 0), (0, 0, 0))
            text1Rect = text1.get_rect()
            text1Rect.topleft = (450, 30)
            screen.blit(text1, text1Rect)
            screen.blit(text,textRect)
            if count==8:
                f2 = pygame.font.SysFont("華文楷體", 25)
                text2 = f2.render("今日積累功德8次,去表白應(yīng)該不會被拒絕太難堪哦", True, (255, 0, 20))
                text2Rect = text.get_rect()
                text2Rect.topleft = (60, 150)
                screen.blit(text2, text2Rect)
            if count==10:
                text = f.render("功德+1", True, (255, 0, 0), (0, 0, 0))
                textRect = text.get_rect()
                textRect.topleft = (30, 30)
                text1 = f1.render("今日積累功德" + str(count) + "次", True, (255, 0, 0))
                text1Rect = text1.get_rect()
                text1Rect.topleft = (450, 30)
                screen.blit(img1, (-180, -100))
                screen.blit(text1, text1Rect)
                screen.blit(text, textRect)
            if count==20:
                f2 = pygame.font.SysFont("華文楷體", 25)
                text3 = f2.render("手速這么快干嘛,這是敲木魚積功德,不是你dfj", True, (230, 90, 80))
                text3Rect = text.get_rect()
                text3Rect.topleft = (60, 150)
                screen.blit(text3, text3Rect)
            if count==22:
                text = f.render("功德+1", True, (255, 0, 0), (0, 0, 0))
                textRect = text.get_rect()
                textRect.topleft = (30, 30)
                text1 = f1.render("今日積累功德" + str(count) + "次", True, (255, 0, 0), (0, 0, 0))
                text1Rect = text1.get_rect()
                text1Rect.topleft = (450, 30)
                screen.blit(img1, (-180, -100))
                screen.blit(text1, text1Rect)
                screen.blit(text, textRect)
            if count==28:
                f2 = pygame.font.SysFont("華文楷體", 25)
                text3 = f2.render("tmd,我看你不是敲木魚,是泄火吧", True, (255, 200, 20))
                text3Rect = text.get_rect()
                text3Rect.topleft = (60, 150)
                screen.blit(text3, text3Rect)
            if count==30:
                text = f.render("功德+1", True, (255, 0, 0), (0, 0, 0))
                textRect = text.get_rect()
                textRect.topleft = (30, 30)
                text1 = f1.render("今日積累功德" + str(count) + "次", True, (255, 0, 0), (0, 0, 0))
                text1Rect = text1.get_rect()
                text1Rect.topleft = (450, 30)
                screen.blit(img1, (-180, -100))
                screen.blit(text1, text1Rect)
                screen.blit(text, textRect)
            if count==40:
                screen.blit(img2, (-210,10))
            if count==41:
                text = f.render("功德+1", True, (255, 0, 0), (0, 0, 0))
                textRect = text.get_rect()
                textRect.topleft = (30, 30)
                text1 = f1.render("今日積累功德" + str(count) + "次", True, (255, 0, 0), (0, 0, 0))
                text1Rect = text1.get_rect()
                text1Rect.topleft = (450, 30)
                screen.blit(img1, (-180, -100))
                screen.blit(text1, text1Rect)
                screen.blit(text, textRect)
            if count==50:
                f2 = pygame.font.SysFont("華文楷體", 25)
                text3 = f2.render("今日功德累計(jì)50次了,小熊后臺獎勵你一只女朋友!", True, (255, 0, 0))
                text3Rect = text.get_rect()
                text3Rect.topleft = (60, 150)
                screen.blit(text3, text3Rect)
                screen.blit(img3, (-300, 0))
            if count==51:
                text = f.render("功德+1", True, (255, 0, 0), (0, 0, 0))
                textRect = text.get_rect()
                textRect.topleft = (30, 30)
                text1 = f1.render("今日積累功德" + str(count) + "次", True, (255, 0, 0), (0, 0, 0))
                text1Rect = text1.get_rect()
                text1Rect.topleft = (450, 30)
                screen.blit(img1, (-180, -100))
                screen.blit(text1, text1Rect)
                screen.blit(text, textRect)



            pygame.display.flip()
        if pygame.Rect.collidepoint(rect1, (ball_x, ball_y)) and event.type==pygame.MOUSEBUTTONUP:
            flag = False

            text = f.render("功德+1", True, (0, 0, 0), (0, 0, 0))
            textRect = text.get_rect()
            textRect.topleft = (30, 30)
            screen.blit(text, textRect)
            if count==40:
                screen.blit(img2, (-210, 10))
            if count==50:
                f2 = pygame.font.SysFont("華文楷體", 25)
                text3 = f2.render("功德積累是好事,凡事有個度!", True, (255, 0, 0))
                text4 = f2.render("小熊后臺檢測到你今日功德累計(jì)50次,看張照片放松一下吧?。?, True, (255, 0, 0))
                text3Rect = text.get_rect()
                text4Rect = text.get_rect()
                text3Rect.topleft = (60, 150)
                text4Rect.topleft = (0, 180)
                screen.blit(img3, (-300, 0))
                screen.blit(text3, text3Rect)
                screen.blit(text4, text4Rect)



            pygame.display.flip()
        if event.type==pygame.QUIT:
            import mouse
            pygame.quit()
    pygame.display.flip()

截圖:

到此這篇關(guān)于Python實(shí)現(xiàn)敲擊木魚積累功德小項(xiàng)目的文章就介紹到這了,更多相關(guān)Python敲擊木魚內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

  • Python WebSocket長連接心跳與短連接的示例

    Python WebSocket長連接心跳與短連接的示例

    這篇文章主要介紹了Python WebSocket長連接心跳與短連接的示例,幫助大家更好的理解和學(xué)習(xí)python,感興趣的朋友可以了解下
    2020-11-11
  • 利用python制作俄羅斯方塊詳細(xì)圖文教程

    利用python制作俄羅斯方塊詳細(xì)圖文教程

    俄羅斯方塊是一款經(jīng)典的游戲,它可以用多種編程語言來實(shí)現(xiàn),這篇文章主要給大家介紹了關(guān)于利用python制作俄羅斯方塊的詳細(xì)圖文教程,文中通過代碼介紹的非常詳細(xì),需要的朋友可以參考下
    2023-10-10
  • Python Web框架之Django框架Model基礎(chǔ)詳解

    Python Web框架之Django框架Model基礎(chǔ)詳解

    這篇文章主要介紹了Python Web框架之Django框架Model基礎(chǔ),結(jié)合實(shí)例形式分析了Django框架Model模型相關(guān)使用技巧與操作注意事項(xiàng),需要的朋友可以參考下
    2019-08-08
  • Python2包含中文報(bào)錯的解決方法

    Python2包含中文報(bào)錯的解決方法

    這篇文章主要給大家介紹了關(guān)于Python2包含中文報(bào)錯的解決方法,文中通過示例代碼詳細(xì)介紹了解決的方法,相信會對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2018-07-07
  • python讀取hdfs上的parquet文件方式

    python讀取hdfs上的parquet文件方式

    這篇文章主要介紹了python讀取hdfs上的parquet文件方式,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2020-06-06
  • python對兩個數(shù)組進(jìn)行合并排列處理的兩種方法

    python對兩個數(shù)組進(jìn)行合并排列處理的兩種方法

    最近遇到數(shù)組合并問題,以此記錄解決方法,供大家參考學(xué)習(xí),下面這篇文章主要給大家介紹了關(guān)于python對兩個數(shù)組進(jìn)行合并排列處理的兩種方法,文中通過實(shí)例代碼介紹的非常詳細(xì),需要的朋友可以參考下
    2023-05-05
  • Python+matplotlib實(shí)現(xiàn)循環(huán)作圖的方法詳解

    Python+matplotlib實(shí)現(xiàn)循環(huán)作圖的方法詳解

    這篇文章主要為大家介紹了Python如何利用matplotlib實(shí)現(xiàn)循環(huán)作圖的,文中的示例代碼講解詳細(xì),感興趣的小伙伴可以跟隨小編一起學(xué)習(xí)學(xué)習(xí)
    2022-06-06
  • 使用python本地部署DeepSeek運(yùn)行時報(bào)錯?OSError:?[WinError?193]?%1?不是有效的?Win32?應(yīng)用程序的問題及解決方法

    使用python本地部署DeepSeek運(yùn)行時報(bào)錯?OSError:?[WinError?193]?%1?不是

    文章介紹了在本地使用Python部署DeepSeek時遇到的OSError:?[WinError?193]?錯誤,通過檢查錯誤信息,發(fā)現(xiàn)與numpy版本有關(guān),解決方法是卸載并重新安裝numpy,最終,問題得到解決,感興趣的朋友跟隨小編一起看看吧
    2025-02-02
  • 一文秒懂Python中的字符串

    一文秒懂Python中的字符串

    這篇文章主要介紹了一文秒懂Python中的字符串,本文給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下
    2021-03-03
  • Python+OpenCV實(shí)現(xiàn)角度測量的示例代碼

    Python+OpenCV實(shí)現(xiàn)角度測量的示例代碼

    本文介紹如何使用python語言實(shí)現(xiàn)角度測量,程序包括鼠標(biāo)選點(diǎn)、直線斜率計(jì)算、角度計(jì)算三個子程序和一個主程序,感興趣的可以了解一下
    2022-03-03

最新評論

乌拉特后旗| 昌都县| 金湖县| 隆尧县| 汉寿县| 大连市| 会同县| 四川省| 双城市| 衡东县| 武陟县| 临桂县| 民和| 隆尧县| 双鸭山市| 随州市| 京山县| 临朐县| 桓台县| 龙口市| 新河县| 金坛市| 涿鹿县| 绥芬河市| 武山县| 清水河县| 深圳市| 青铜峡市| 潼关县| 容城县| 襄城县| 霍城县| 简阳市| 巴青县| 漠河县| 历史| 齐河县| 肥乡县| 敦化市| 巴中市| 汕头市|