欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Python+Pygame實(shí)戰(zhàn)之炫舞小游戲的實(shí)現(xiàn)

 更新時間:2022年12月02日 14:05:13   作者:顧木子吖  
提到QQ炫舞,可能很多人想到的第一個詞是“青春”?;腥婚g,這個承載了無數(shù)人回憶與時光的游戲品牌,已經(jīng)走到了第十幾個年頭。今天小編就來給大家嘗試做一款簡單的簡陋版的小游戲——《舞動青春*炫舞》,感興趣的可以了解一下

導(dǎo)語

昨天去老姐家里蹭飯,進(jìn)門的時候就看到佳佳妹(我姐的女兒)低頭霹靂吧啦一頓操作猛如虎,飯好了都還在玩兒,什么東西這么好玩?一走進(jìn)就看到這是一款酷似炫舞的小游戲。(死去的回憶突然在攻擊我~沒想到現(xiàn)在還有這款游戲就是不知道升級了多少次啦)

不知道你們還記不記得曾經(jīng)有個風(fēng)靡一時的舞蹈游戲炫舞。

我讀小學(xué)的時候,大概是09年吧,這個游戲非?;鸨绻闳ゾW(wǎng)吧,十個女生里,有十一個都是在玩炫舞,像我就是其中的一員。那個時候還沒有英雄聯(lián)盟王者榮耀,女生玩炫舞,男生玩地下城穿越火線!

提到QQ炫舞,可能很多人想到的第一個詞是“青春”?;腥婚g,這個承載了無數(shù)人回憶與時光的游戲品牌,已經(jīng)走到了第十幾個年頭。今天小編就來給大家嘗試做一款簡單的簡陋版的小游戲——《舞動青春*炫舞》。(其實(shí)是簡單的五分之一的成品,感覺今天洗頭發(fā)又要掉一堆了)

一、環(huán)境安裝

小編使用的環(huán)境:Python3、Pycharm社區(qū)版、pygame模塊,部分自帶的就不一一 展示啦。

模塊安裝:pip install -i https://pypi.douban.com/simple/+模塊名 

背景圖片大家可以自己修改的啦~嘿嘿怎么好看怎么來撒!

二、代碼展示

主程序:

import pygame
import sys
import random
 
import time
import threading
 
random.random()
flag=1
 
# 創(chuàng)建線程對象
 
 
# 初始化pygame
pygame.init()
# 定義變量
size = width, height = 1024,768
bg = (0, 0, 0)
# 加載logo圖
 
img = pygame.image.load("shang_hong.png")
# 獲取圖像的位置
 
# 創(chuàng)建一個主窗口
screen = pygame.display.set_mode(size)
 
# 標(biāo)題
pygame.display.set_caption("炫舞——簡潔版")
    # 創(chuàng)建游戲主循環(huán)
clock = pygame.time.Clock()  
sudu=0.5
list=[]
list1=[]
 
def fuyuan():
    x=50
    global list1,list
    list.clear()
    for i in range(1,10):
        
        list.append(list1[i-1])
        
    for i in list1:
        
        if i==1:
            img = pygame.image.load("zuo_hong.png")
            screen.blit(img, [x,500])
            pygame.display.flip()
        if i==2:
            img = pygame.image.load("shang_hong.png")
            screen.blit(img, [x,500])
            pygame.display.flip()
        if i==3:
            img = pygame.image.load("you_hong.png")
            screen.blit(img, [x,500])
            pygame.display.flip()
        if i==4:
            img = pygame.image.load("xia_hong.png")
            screen.blit(img, [x,500])
            pygame.display.flip()
        x=x+113
    x=50                    
def chushi():
    global x
    x=50
 
    screen.fill(bg)
    global list
    global list1
    list.clear()
    list1.clear()
    for i in range(1,9):
        i=random.randint(1,4)
        list.append(i)
    list.append(5)
    #print(list)
  
    
    for i in range(1,10):   
        list1.append(list[i-1])
    #print(list1)
    
    img = pygame.image.load("jindu.jpg")
    screen.blit(img, [100,400])
    pygame.display.flip()
    x=50
    for i in list:
        
        if i==1:
            img = pygame.image.load("zuo_hong.png")
            screen.blit(img, [x,500])
            pygame.display.flip()
        if i==2:
            img = pygame.image.load("shang_hong.png")
            screen.blit(img, [x,500])
            pygame.display.flip()
        if i==3:
            img = pygame.image.load("you_hong.png")
            screen.blit(img, [x,500])
            pygame.display.flip()
        if i==4:
            img = pygame.image.load("xia_hong.png")
            screen.blit(img, [x,500])
            pygame.display.flip()
        x=x+113
    x=50
        
x1=150
flag=1
def yidong():
    #print("sss")
    global flag
    global list
    global x1
    global clock
    clock.tick(800)
    #print(x1)
    img = pygame.image.load("jindu.jpg")
    screen.blit(img, [100,400])   
    pygame.draw.circle(screen,(232,0,176),(x1,431),20,1000)
    #print(x1)
    pygame.display.flip()
    x1=x1+sudu
    if x1>780:
        #print(len(list))
        if len(list)==0:
            while x1<780:
                flag=0
                #print(x1)
                clock.tick(800)
                #print(x1)
                img = pygame.image.load("jindu.jpg")
                screen.blit(img, [100,400])   
                pygame.draw.circle(screen,(232,0,176),(x1,431),20,1000)
                pygame.display.flip()
                x1=x1+sudu 
            flag=1    
            #chushi()
            #list.clear()
            
            
        x1=150 
        if len(list)>0:
             
            screen.fill((0,0,0))
            miss()
            while x1<780:
                flag=0
                #print(x1)
                clock.tick(800)
                #print(x1)
                img = pygame.image.load("jindu.jpg")
                screen.blit(img, [100,400])   
                pygame.draw.circle(screen,(232,0,176),(x1,431),20,1000)
                pygame.display.flip()
                x1=x1+sudu
            x1=150    
            flag=1
        chushi()
   
 
class task(threading.Thread):
     def __init__(self):
         threading.Thread.__init__(self)
         self.thread_stop = False
     def run(self):
        while not self.thread_stop:
            yidong()
        
        
           
     def stop(self):
        self.thread_stop = True 
        
t1 = task()
t1.start()
 
#yidong()
 
 
 
 
chushi()
x=50
def miss():
    font = pygame.font.Font(None, 150)
    text = font.render('Miss!', True, (232,0,176), (0, 0, 0))
    screen.blit(text, (200, 150))
    
def chenggong():
    global x1
    
    screen.fill((0,0,0))
    global x
    global flag
    x=50
    flag=0
    if x1<600:
        font = pygame.font.Font(None, 150)
        text = font.render('Good!', True, (232,0,176), (0, 0, 0))
        screen.blit(text, (200, 150))
    if x1>625:
        font = pygame.font.Font(None, 150)
        text = font.render('Good!', True, (232,0,176), (0, 0, 0))
        screen.blit(text, (200, 150))
    if x1>=600 and x1<=625:
        font = pygame.font.Font(None, 150)
        text = font.render('Perfict!', True, (232,0,176), (0, 0, 0))
        screen.blit(text, (200, 150))
    x1=150    
        
while True:
    clock.tick(100)
    
    # 設(shè)置初始值
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            sys.exit()
        # 圖像移動 KEYDOWN 鍵盤按下事件
        # 通過 key 屬性對應(yīng)按鍵
        cmd=1
        if event.type == pygame.KEYDOWN and flag==1:
            #print("sssss")
            #if event.key == 27:
            #   cmd=2
            if event.key == pygame.K_ESCAPE:
                t1.stop()
                sys.exit()
            if event.key == pygame.K_UP:
                cmd=2
            if event.key == pygame.K_DOWN:
                cmd=4
            if event.key == pygame.K_RIGHT:
                cmd=3
            if event.key == pygame.K_LEFT:
                cmd=1
            if event.key == pygame.K_SPACE:
                cmd=5
                if len(list)==1:
                    del list[0]
                    chenggong() 
                     
                    
                    continue
                
            
            if cmd==list[0]:
                
                if cmd==1:
                    #print(x)
                    img = pygame.image.load("zuo_lv.png")
                    screen.blit(img, [x,500])
                    pygame.display.flip()
                    
                if cmd==2:
                    #print(x)
                    img = pygame.image.load("shang_lv.png")
                    screen.blit(img, [x,500])
                    pygame.display.flip()
                   
                if cmd==3:
                    #print(x)
                    img = pygame.image.load("you_lv.png")
                    screen.blit(img, [x,500])
                    pygame.display.flip()   
                    
                    
                if cmd==4:
                    #print(x)
                    img = pygame.image.load("xia_lv.png")
                    screen.blit(img, [x,500])
                    pygame.display.flip()
 
                x=x+113
                del list[0]
            else:
                print(list1)
                #print("Aaaa")
                fuyuan()
                x=50
                
                
                
                   
           
            #print("sss")
            #screen.fill((0,0,0))
            
           
            
            
    '''
    # 移動圖像
    position = position.move(site)
    # 填充背景
    screen.fill(bg)
    # 放置圖片
    screen.blit(img, position)
    # 更新顯示界面
    pygame.display.flip()
    '''

三、效果展示

1)簡潔版炫舞

?2)隨機(jī)截圖

3)MISS節(jié)拍

以上就是Python+Pygame實(shí)戰(zhàn)之炫舞小游戲的實(shí)現(xiàn)的詳細(xì)內(nèi)容,更多關(guān)于Python Pygame炫舞游戲的資料請關(guān)注腳本之家其它相關(guān)文章!

相關(guān)文章

  • python實(shí)現(xiàn)傅里葉級數(shù)展開的實(shí)現(xiàn)

    python實(shí)現(xiàn)傅里葉級數(shù)展開的實(shí)現(xiàn)

    這篇文章主要介紹了python實(shí)現(xiàn)傅里葉級數(shù)展開的實(shí)現(xiàn),小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2018-07-07
  • tensorflow 打印內(nèi)存中的變量方法

    tensorflow 打印內(nèi)存中的變量方法

    今天小編就為大家分享一篇tensorflow 打印內(nèi)存中的變量方法,具有很好的參考價(jià)值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2018-07-07
  • python如何將txt文件的內(nèi)容逐行讀取轉(zhuǎn)化成數(shù)組

    python如何將txt文件的內(nèi)容逐行讀取轉(zhuǎn)化成數(shù)組

    這篇文章主要介紹了python如何將txt文件的內(nèi)容逐行讀取轉(zhuǎn)化成數(shù)組問題,具有很好的參考價(jià)值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教
    2023-03-03
  • Pandas修改DataFrame列名的兩種方法實(shí)例

    Pandas修改DataFrame列名的兩種方法實(shí)例

    這篇文章主要給大家介紹了關(guān)于Pandas修改DataFrame列名的兩種方法,文中通過實(shí)例代碼介紹的非常詳細(xì),對大家學(xué)習(xí)或者使用Pandas具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下
    2022-03-03
  • OpenCV中VideoCapture類的使用詳解

    OpenCV中VideoCapture類的使用詳解

    這篇文章主要介紹了OpenCV中VideoCapture類的使用詳解,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2020-02-02
  • Python判斷變量名是否合法的方法示例

    Python判斷變量名是否合法的方法示例

    今天小編就為大家分享一篇關(guān)于Python判斷變量名是否合法的方法示例,小編覺得內(nèi)容挺不錯的,現(xiàn)在分享給大家,具有很好的參考價(jià)值,需要的朋友一起跟隨小編來看看吧
    2019-01-01
  • 簡單掌握Python中g(shù)lob模塊查找文件路徑的用法

    簡單掌握Python中g(shù)lob模塊查找文件路徑的用法

    glob模塊遵循Unix的shell規(guī)則來匹配文件名進(jìn)行文件查找,下面我們結(jié)合匹配相關(guān)的字符區(qū)間與通配符知識,來簡單掌握Python中g(shù)lob模塊查找文件路徑的用法
    2016-07-07
  • 利用Python制作一個動物識別小程序

    利用Python制作一個動物識別小程序

    動物識別是計(jì)算機(jī)視覺和模式識別領(lǐng)域的重要研究方向,它涉及通過圖像或視頻數(shù)據(jù)自動識別和分類不同種類的動物,隨著數(shù)字圖像技術(shù)和機(jī)器學(xué)習(xí)方法的快速發(fā)展,動物識別在實(shí)際應(yīng)用中具有廣泛的潛力,本文將給大家介紹如何基于Python制作一個動物識別小程序
    2023-10-10
  • Python中異常的捕獲與處理詳解

    Python中異常的捕獲與處理詳解

    這篇文章主要介紹了Python中異常的捕獲與處理詳解,調(diào)試Python程序時,經(jīng)常會報(bào)出一些異常,異常的原因一方面可能是寫程序時由于疏忽或者考慮不全造成了錯誤,這時就需要根據(jù)異常Traceback到出錯點(diǎn),進(jìn)行分析改正,需要的朋友可以參考下
    2023-08-08
  • 分享Pytorch獲取中間層輸出的3種方法

    分享Pytorch獲取中間層輸出的3種方法

    這篇文章主要給大家分享了Pytorch獲取中間層輸出的3種方法,文章內(nèi)容介紹詳細(xì),需要的小伙伴可以參考一下,希望對你的學(xué)習(xí)或工作有所幫助
    2022-03-03

最新評論