国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

【Python】pygame彈球游戲?qū)崿F(xiàn)

這篇具有很好參考價(jià)值的文章主要介紹了【Python】pygame彈球游戲?qū)崿F(xiàn)。希望對(duì)大家有所幫助。如果存在錯(cuò)誤或未考慮完全的地方,請(qǐng)大家不吝賜教,您也可以點(diǎn)擊"舉報(bào)違法"按鈕提交疑問(wèn)。

彈球游戲?qū)崿F(xiàn)

游戲源碼:

import pygame,pygame_os,random,math
"""
磚塊設(shè)定:80*30 一個(gè)磚塊 其中 70*20是有顏色的,邊緣的5*5(四周)是白色--為了區(qū)分塊與塊之間
        總塊數(shù)在10*13=130塊,第一行是(0,0)-(0,9);第二行是(1,0)-(1,9)如此類推,用random函數(shù)進(jìn)行隨機(jī)放置方塊
"""

# 查找數(shù)組元素
def find(list, num):
    try:
        index = list.index(num)
    except:
        return -1
    else:
        return index

# 初始變量
white = (255, 255, 255)
red = (255, 0, 0)
green = (0, 255, 0)
yellow = (255, 255, 0)
font_file = "IPix中文像素字體.ttf"
win_width, win_height, bg_color, caption_title = (800, 600, white, "彈球游戲")
clock = pygame.time.Clock()

if __name__ == '__main__':
    # 程序死循環(huán)
    while 1:
        # 初始游戲窗口
        window_init = pygame_os.Start_Name(win_width, win_height, bg_color, caption_title)
        window = pygame_os.Start_Name.start_init(window_init)

        # 初始游戲開(kāi)始界面
        pygame_os.Font.set_font(window, font_file, 45, "歡迎來(lái)到彈球游戲", (255, 0, 0),"top")
        for i in range(3):
            button_pos = ((win_width - 200)/2, 200 + 100 * i)
            button_name = ["簡(jiǎn)單難度", "普通難度", "困難難度"]
            locals()[f"button_{i}"] = pygame_os.Button(window, (255, 0, 0), button_pos, 200, 50, font_file, 30, white, button_name[i])
            pygame_os.Button.set_button(locals()[f"button_{i}"])


        #游戲選擇難度while循環(huán)
        Start_bool = True
        difficulty = None
        tem_bool = True # 控制只執(zhí)行一次的按鈕if判斷
        while Start_bool:
            for event in pygame.event.get():
                # 當(dāng)按鈕經(jīng)過(guò)時(shí):
                if event.type == pygame.MOUSEMOTION:
                    # 簡(jiǎn)單難度按鈕
                    if (win_width - 200)/2 <= event.pos[0] <= (win_width + 200)/2 and 200 <= event.pos[1] <=250:
                        if tem_bool == True:
                            pygame_os.Button.button_MOUSEMOTION(button_0)
                            tem_bool = False
                    # 普通難度按鈕
                    elif (win_width - 200)/2 <= event.pos[0] <= (win_width + 200)/2 and 300 <= event.pos[1] <=350:
                        if tem_bool == True:
                            pygame_os.Button.button_MOUSEMOTION(button_1)
                            tem_bool = False
                    # 困難難度按鈕
                    elif (win_width - 200)/2 <= event.pos[0] <= (win_width + 200)/2 and 400 <= event.pos[1] <=450:
                        if tem_bool == True:
                            pygame_os.Button.button_MOUSEMOTION(button_2)
                            tem_bool = False
                    #重畫(huà)
                    else:
                        pygame_os.Button.button_MOUSEMOTION_end(button_0)
                        pygame_os.Button.button_MOUSEMOTION_end(button_1)
                        pygame_os.Button.button_MOUSEMOTION_end(button_2)
                        tem_bool = True

                # 當(dāng)按鈕按下時(shí):
                if event.type == pygame.MOUSEBUTTONDOWN:
                    # 簡(jiǎn)單難度按鈕
                    if (win_width - 200) / 2 <= event.pos[0] <= (win_width + 200) / 2 and 200 <= event.pos[1] <= 250:
                            pygame_os.Button.button_MOUSEDOWN(button_0)
                            difficulty = 0
                    # 普通難度按鈕
                    elif (win_width - 200) / 2 <= event.pos[0] <= (win_width + 200) / 2 and 300 <= event.pos[1] <= 350:
                            pygame_os.Button.button_MOUSEDOWN(button_1)
                            difficulty = 1
                    # 困難難度按鈕
                    elif (win_width - 200) / 2 <= event.pos[0] <= (win_width + 200) / 2 and 400 <= event.pos[1] <= 450:
                            pygame_os.Button.button_MOUSEDOWN(button_2)
                            difficulty = 2
                # 當(dāng)按鈕松開(kāi)時(shí):
                if event.type == pygame.MOUSEBUTTONUP:
                    # 簡(jiǎn)單難度按鈕
                    if (win_width - 200) / 2 <= event.pos[0] <= (win_width + 200) / 2 and 200 <= event.pos[1] <= 250:
                            pygame_os.Button.button_MOUSEUP(button_0)
                            Start_bool = False
                            break
                    # 普通難度按鈕
                    elif (win_width - 200) / 2 <= event.pos[0] <= (win_width + 200) / 2 and 300 <= event.pos[1] <= 350:
                            pygame_os.Button.button_MOUSEUP(button_1)
                            Start_bool = False
                            break
                    # 困難難度按鈕
                    elif (win_width - 200) / 2 <= event.pos[0] <= (win_width + 200) / 2 and 400 <= event.pos[1] <= 450:
                            pygame_os.Button.button_MOUSEUP(button_2)
                            Start_bool = False
                            break

                # 退出游戲代碼
                if event.type == pygame.QUIT:exit()

        # 清屏
        pygame.draw.rect(window, white, (0, 0, win_width, win_height))
        pygame.display.update()

        # 畫(huà)長(zhǎng)板以及小球
        plank_size = 25 + 50 * (3 - difficulty)
        pygame.draw.rect(window, red, ((win_width - plank_size) / 2, 500, plank_size, 10))
        pygame.draw.circle(window, green, (win_width / 2, 490), 10)
        pygame.display.update()

        # 游戲開(kāi)始設(shè)置開(kāi)關(guān)
        Start_bool = True

        last_x, last_y, last_plank_x = win_width / 2, 490, (win_width - plank_size) / 2
        while Start_bool:
            for event in pygame.event.get():
                # 長(zhǎng)板隨著鼠標(biāo)移動(dòng)而移動(dòng)
                if event.type == pygame.MOUSEMOTION:
                    if event.pos[1] >= 500:
                        pygame.draw.rect(window, white, (0, 500, win_width, 10))
                        pygame.draw.rect(window, red, (event.pos[0] - plank_size/2, 500, plank_size, 10))
                        pygame.draw.rect(window, white, (0, 480, win_width, 20))
                        last_x, last_y, last_plank_x = event.pos[0], 490, event.pos[0] - plank_size/2
                        pygame.draw.circle(window, green, (last_x, last_y), 10)
                        pygame.display.update()
                if event.type == pygame.MOUSEBUTTONUP:
                    angle = random.choice(range(20,60))
                    x_speed = math.cos(math.radians(angle)) * (difficulty * 3 + 5)
                    y_speed = - math.sin(math.radians(angle)) * (difficulty * 3 + 5)
                    Start_bool = False
                    break
                # 退出游戲代碼
                if event.type == pygame.QUIT:exit()

        # 磚塊放置函數(shù)
        brick_list = []
        def set_brick(difficulty):
            global brick_list, last_x, last_y
            brick_list = []
            tem_list = []
            # 設(shè)立磚塊數(shù)列
            for row in range(10):
                for column in range(13):
                    brick_list.append([row, column, False])
            brick_num = random.choice(range(50 + 20 * difficulty, 80 + 20 * difficulty))
            # 刪除球附近的磚塊
            index = find(brick_list, [int((last_x-10)/80),int((last_y-10)/30), False])
            if index != -1:
                del brick_list[index]

            index = find(brick_list, [int((last_x + 10) / 80), int((last_y - 10) / 30), False])
            if index != -1:
                del brick_list[index]

            index = find(brick_list, [int((last_x - 10) / 80), int((last_y + 10) / 30), False])
            if index != -1:
                del brick_list[index]

            index = find(brick_list, [int((last_x + 10) / 80), int((last_y + 10) / 30), False])
            if index != -1:
                del brick_list[index]

            # 隨機(jī)磚塊數(shù)列
            for i in range(len(brick_list)):
                tem_list.append(i)
            for num in range(brick_num):
                random_num = random.choice(range(len(tem_list)))
                brick_list[tem_list[random_num]][2] = True
                del tem_list[random_num]
            # 構(gòu)建被抽中磚塊
            for num in range(len(brick_list)):
                if brick_list[num][2] == True:
                    random_color = (
                        random.choice(range(50, 200)),
                        random.choice(range(50, 200)),
                        random.choice(range(50, 200))
                    )
                    x = 80*brick_list[num][0]+5
                    y = 30*brick_list[num][1]+5
                    pygame.draw.rect(window, random_color, (x, y, 70, 20))



        # 游戲正式開(kāi)始
        game_score = 0
        while True:
            # 刷新分?jǐn)?shù)
            pygame.draw.rect(window, white, (0, 530, win_width, win_height - 530))
            pygame_os.Font.set_font(window, font_file, 30, "目前得分:{0}".format(game_score), (0, 0, 0), (0, 550))
            # 無(wú)盡模式磚塊打完刷新
            Start_bool = False
            tem_num = 0
            for brick in brick_list:
                if brick[2] == True:
                    tem_num += 1
            if tem_num >= 5:
                Start_bool = True
            if Start_bool == False:
                pygame.draw.rect(window, white, (0, 0, win_width, 490))
                set_brick(difficulty)

            # 畫(huà)球的運(yùn)動(dòng)軌跡
            pygame.draw.circle(window, white, (last_x, last_y), 10)
            last_x += x_speed
            last_y += y_speed
            pygame.draw.circle(window, green, (last_x , last_y), 10)
            # 碰到邊緣反彈
            if last_x + 10 >= win_width or last_x - 10 <= 0:
                x_speed = -x_speed
            if (last_y <= 500 <= last_y + 10 and last_plank_x <= last_x <= last_plank_x + plank_size) or last_y - 10 <= 0:
                y_speed = -y_speed

            # 畫(huà)邊緣線
            pygame.draw.line(window, (0, 0, 0), (0, 0), (win_width, 0), 2)
            pygame.draw.line(window, (0, 0, 0), (0, 0), (0, 498), 2)
            pygame.draw.line(window, (0, 0, 0), (win_width - 2, 0), (win_width - 2, 498), 2)
            pygame.draw.line(window, (0, 0, 0), (0, 498), (win_width, 498), 2)

            # 畫(huà)長(zhǎng)板
            pygame.draw.rect(window, red, (last_plank_x, 500, plank_size, 10))

            # 判斷磚塊碰撞消失
                # 碰撞刪除磚塊
            def clean_break(window, pos_x, pos_y, ball_last_x, ball_last_y):
                global white
                x = 80 * pos_x + 5
                y = 30 * pos_y + 5
                pygame.draw.rect(window, white, (x, y, 70, 20))
                # 重新畫(huà)球
                pygame.draw.circle(window, green, (last_x, last_y), 10)
                pygame.display.update()

                # 從磚塊左邊碰撞
            judge_x = int((last_x+10)/80)
            judge_y = int(last_y/30)
            index = find(brick_list, [judge_x, judge_y, True])
            if index != -1 and x_speed > 0:
                brick_list[index][2] = False
                game_score += 1
                x_speed = -x_speed
                clean_break(window, judge_x, judge_y, last_x, last_y)

                # 從磚塊右邊碰撞
            judge_x = int((last_x-10)/80)
            judge_y = int(last_y/30)
            index = find(brick_list, [judge_x, judge_y, True])
            if index != -1 and x_speed < 0:
                brick_list[index][2] = False
                game_score += 1
                x_speed = -x_speed
                clean_break(window, judge_x, judge_y, last_x, last_y)

                # 從磚塊上邊碰撞
            judge_x = int(last_x/80)
            judge_y = int((last_y+10)/30)
            index = find(brick_list, [judge_x, judge_y, True])
            if index != -1 and y_speed > 0:
                brick_list[index][2] = False
                game_score += 1
                y_speed = -y_speed
                clean_break(window, judge_x, judge_y, last_x, last_y)

                # 從磚塊下邊碰撞
            judge_x = int(last_x/80)
            judge_y = int((last_y-10)/30)
            index = find(brick_list, [judge_x, judge_y, True])
            if index != -1 and y_speed < 0:
                brick_list[index][2] = False
                game_score += 1
                y_speed = -y_speed
                clean_break(window, judge_x, judge_y, last_x, last_y)

            pygame.display.update()

            # 判斷Gameover
            if last_y > 525:
                pygame.draw.circle(window, white, (last_x, last_y), 10)
                pygame.draw.rect(window, red, (last_plank_x, 500, plank_size, 10))
                pygame.display.update()
                break

            for event in pygame.event.get():
                if event.type == pygame.MOUSEMOTION:
                    if event.pos[1] >= 500:
                        last_plank_x = event.pos[0] - plank_size / 2
                        pygame.draw.rect(window, white, (0, 500, win_width, 10))
                        pygame.draw.rect(window, red, (last_plank_x, 500, plank_size, 10))

                    pygame.display.update()

                if event.type == pygame.QUIT: exit()
            # 限制最大幀數(shù)為60
            clock.tick(60)

        # 畫(huà)Gameover畫(huà)面
        Start_bool = True
        tem_bool = True  # 控制只執(zhí)行一次的按鈕if判斷
        while Start_bool:
            pygame.draw.rect(window, (128, 128, 128), (0, 0, win_width, win_height / 4))
            pygame.display.update()
            clock.tick(1)
            pygame.draw.rect(window, (128, 128, 0), (0, win_height / 4, win_width, win_height*2 / 4))
            pygame.display.update()
            clock.tick(1)
            pygame.draw.rect(window, (128, 0, 128), (0, win_height*2 / 4, win_width, win_height*3 / 4))
            pygame.display.update()
            clock.tick(1)
            pygame.draw.rect(window, (0, 128, 128), (0, win_height*3 / 4, win_width, win_height))
            pygame.display.update()
            clock.tick(1)
            Start_bool = False
        # 畫(huà)結(jié)束按鈕
        button_pos = ((win_width - 200)/2, 350)
        button_refresh_init = pygame_os.Button(window, (255, 0, 0), button_pos, 200, 50, font_file, 30, white, "重來(lái)")
        pygame_os.Button.set_button(button_refresh_init)

        button_pos = ((win_width - 200)/2, 450)
        button_end_init = pygame_os.Button(window, (255, 0, 0), button_pos, 200, 50, font_file, 30, white, "退出")
        pygame_os.Button.set_button(button_end_init)

        # 畫(huà)GAMEOVER字樣
        pygame_os.Font.set_font(window, "IPix中文像素字體.ttf", 45, "GAMEOVER", (0, 0, 0), "center")

        pygame.display.update()

        Start_bool = True
        while Start_bool:
            for event in pygame.event.get():
                if event.type == pygame.MOUSEMOTION:
                    if (win_width - 200) / 2 <= event.pos[0] <= (win_width + 200) / 2 and 350 <= event.pos[1] <= 400:
                        if tem_bool == True:
                            pygame_os.Button.button_MOUSEMOTION(button_refresh_init)
                            tem_bool = False
                    elif (win_width - 200) / 2 <= event.pos[0] <= (win_width + 200) / 2 and 450 <= event.pos[1] <= 500:
                        if tem_bool == True:
                            pygame_os.Button.button_MOUSEMOTION(button_end_init)
                            tem_bool = False
                    # 重畫(huà)
                    else:
                        pygame_os.Button.button_MOUSEMOTION_end(button_refresh_init)
                        pygame_os.Button.button_MOUSEMOTION_end(button_end_init)
                        tem_bool = True

                if event.type == pygame.MOUSEBUTTONDOWN:
                    if (win_width - 200) / 2 <= event.pos[0] <= (win_width + 200) / 2 and 350 <= event.pos[1] <= 400:
                        pygame_os.Button.button_MOUSEDOWN(button_refresh_init)
                    if (win_width - 200) / 2 <= event.pos[0] <= (win_width + 200) / 2 and 450 <= event.pos[1] <= 500:
                        pygame_os.Button.button_MOUSEDOWN(button_end_init)

                if event.type == pygame.MOUSEBUTTONUP:
                    if (win_width - 200) / 2 <= event.pos[0] <= (win_width + 200) / 2 and 350 <= event.pos[1] <= 400:
                        pygame_os.Button.button_MOUSEUP(button_refresh_init)
                        Start_bool = False
                    if (win_width - 200) / 2 <= event.pos[0] <= (win_width + 200) / 2 and 450 <= event.pos[1] <= 500:
                        pygame_os.Button.button_MOUSEUP(button_end_init)
                        exit()

                if event.type == pygame.QUIT:exit()


"""
①道具
②磚塊消失 √
③分裂球
④按Esc游戲暫停且跳出窗口
"""

pygame_os庫(kù):文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-525510.html

import pygame


class Start_Name:
    def __init__(self, win_width, win_height, bg_color, caption_title):
        self.win_width = win_width
        self.win_height = win_height
        self.bg_color = bg_color
        self.caption_title = caption_title

    def start_init(self):
        pygame.init()
        window = pygame.display.set_mode((self.win_width, self.win_height))
        pygame.display.set_caption(self.caption_title)
        window.fill(self.bg_color)
        return window


class Button:
    def __init__(self, window, button_color, pos, width, height, font_name, font_size, font_color, font_text):
        self.window = window
        self.button_color = button_color
        self.pos = pos
        self.width = width
        self.height = height
        self.font_name = font_name
        self.font_size = font_size
        self.font_color = font_color
        self.font_text = font_text
        self.button_tem_DU_color = button_color
        self.button_tem_motion_color = button_color

    def set_button(self):
        x, y = self.pos
        pygame.draw.rect(self.window, self.button_color, (x, y, self.width, self.height))
        font01 = pygame.font.Font(self.font_name, self.font_size)
        text01 = font01.render(self.font_text, True, self.font_color)
        w, h = text01.get_size()
        self.window.blit(text01, (x + (self.width - w) / 2, y + (self.height - h) / 2))
        pygame.display.update()
        return text01

    def button_MOUSEDOWN(self):
        self.button_tem_DU_color = self.button_color
        self.button_color = (128, 128, 128)
        Button.set_button(self)
        return True

    def button_MOUSEMOTION(self):
        self.button_tem_motion_color = self.button_color
        self.button_color = (175, 175, 175)
        Button.set_button(self)
        return True

    def button_MOUSEUP(self):
        self.button_color = self.button_tem_DU_color
        Button.set_button(self)
        return True

    def button_MOUSEMOTION_end(self):
        self.button_color = self.button_tem_motion_color
        Button.set_button(self)
        return True


class Font:
    @staticmethod
    def set_font(window, font_file, font_size, text, font_color, text_pos):
        font01 = pygame.font.Font(font_file, font_size)
        text01 = font01.render(text, True, font_color)
        if text_pos == "top":
            text_pos = ((window.get_size()[0] - text01.get_size()[0])/2, 0)
        if text_pos == "bottom":
            text_pos = (0, (window.get_size()[1] - text01.get_size()[1]) / 2)
        if text_pos == "center":
            text_pos = ((window.get_size()[0] - text01.get_size()[0])/2, (window.get_size()[1] - text01.get_size()[1])/2)
        window.blit(text01, text_pos)
        pygame.display.update()
        return text01

到了這里,關(guān)于【Python】pygame彈球游戲?qū)崿F(xiàn)的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來(lái)自互聯(lián)網(wǎng)用戶投稿,該文觀點(diǎn)僅代表作者本人,不代表本站立場(chǎng)。本站僅提供信息存儲(chǔ)空間服務(wù),不擁有所有權(quán),不承擔(dān)相關(guān)法律責(zé)任。如若轉(zhuǎn)載,請(qǐng)注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實(shí)不符,請(qǐng)點(diǎn)擊違法舉報(bào)進(jìn)行投訴反饋,一經(jīng)查實(shí),立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費(fèi)用

相關(guān)文章

  • python | 基礎(chǔ)學(xué)習(xí)(六)pygame游戲開(kāi)發(fā):飛機(jī)大戰(zhàn)

    python | 基礎(chǔ)學(xué)習(xí)(六)pygame游戲開(kāi)發(fā):飛機(jī)大戰(zhàn)

    pygame 模塊,轉(zhuǎn)為電子游戲設(shè)計(jì) $ sudo pip3 install pygame windows: pip install pygame (1)新建項(xiàng)目 飛機(jī)大戰(zhàn) (2)新建文件 pygame.py (3)建立游戲窗口: ①pygame的初始化和退出 pygame.init() :導(dǎo)入并初始化所有pygame模塊,使用其他模塊之前,必須先調(diào)用init方法。 pygame.quit() :卸載所有

    2024年02月08日
    瀏覽(28)
  • 【python】 pygame學(xué)習(xí)示例 --飛機(jī)大戰(zhàn)小游戲制作

    【python】 pygame學(xué)習(xí)示例 --飛機(jī)大戰(zhàn)小游戲制作

    python版本:3.8.5 所需模塊:pygame random os pygame版本:20.1 開(kāi)發(fā)環(huán)境:pycharm專業(yè)版 硬件環(huán)境:win11 8G內(nèi)存以上 使用python的第三方庫(kù)–pygame 制作飛機(jī)大戰(zhàn)小游戲 小游戲的內(nèi)容包括: 玩家player的移動(dòng) 子彈的發(fā)射 隕石的隨機(jī)掉落(包括旋轉(zhuǎn) 大小 下落角度) 玩家 子彈 隕石的碰撞交互

    2024年02月04日
    瀏覽(23)
  • 基于Python pygame簡(jiǎn)易版斗獸棋小游戲源代碼

    基于Python pygame簡(jiǎn)易版斗獸棋小游戲源代碼

    基于Python pygame簡(jiǎn)易版斗獸棋小游戲源代碼 游戲規(guī)則如下: 勝利條件: 1.吃掉對(duì)方全部棋子 2.走入對(duì)方獸穴(不可進(jìn)入自己洞穴) 吃法: 1.象獅虎豹狼狗貓鼠象 2.同類棋子先行者吃掉對(duì)方 3.老鼠可以進(jìn)河,老鼠在河里時(shí),岸上的動(dòng)物不能捕食他,他也不能捕食岸上的動(dòng)物 4.獅虎在河中沒(méi)

    2023年04月09日
    瀏覽(101)
  • Python利用pygame實(shí)現(xiàn)飛機(jī)大戰(zhàn)游戲

    Python利用pygame實(shí)現(xiàn)飛機(jī)大戰(zhàn)游戲

    文章目錄: 一:運(yùn)行效果 1.演示 2.思路和功能 二:代碼 文件架構(gòu) Demo 必備知識(shí):python圖形化編程pygame游戲模塊 效果圖 ?????? Python利用pygame實(shí)現(xiàn)飛機(jī)大戰(zhàn)游戲運(yùn)行演示 參考:【Python游戲】1小時(shí)開(kāi)發(fā)飛機(jī)大戰(zhàn)游戲-Pygame版本(1小時(shí)40分鐘) 博主提取資源: 提取

    2024年04月09日
    瀏覽(36)
  • Python “貪吃蛇”游戲,在不斷改進(jìn)中學(xué)習(xí)pygame編程

    Python “貪吃蛇”游戲,在不斷改進(jìn)中學(xué)習(xí)pygame編程

    目錄 前言 改進(jìn)過(guò)程一 增加提示信息 原版幫助摘要 pygame.draw pygame.font class Rect class Surface 改進(jìn)過(guò)程二 增加顯示得分 改進(jìn)過(guò)程三 增加背景景樂(lè) 增加提示音效 音樂(lè)切換 靜音切換 mixer.music.play 注意事項(xiàng) 原版幫助摘要 pygame.mixer pygame.mixer.Sound 改進(jìn)過(guò)程四 增加WASD方向鍵 增加退出事

    2024年02月12日
    瀏覽(33)
  • Python版基于pygame的瑪麗快跑小游戲源代碼,瑪麗冒險(xiǎn)小游戲代碼,支持雙人模式

    Python版基于pygame的瑪麗快跑小游戲源代碼,瑪麗冒險(xiǎn)小游戲代碼,支持雙人模式

    基于pygame的瑪麗快跑小游戲源代碼,瑪麗冒險(xiǎn)小游戲代碼,支持雙人模式 按空格進(jìn)入單人模式,按‘t’進(jìn)入雙人模式,雙人模式下瑪麗1采用空格鍵上跳,瑪麗2采用方向上鍵上跳。 完整代碼下載地址:Python版基于pygame的瑪麗快跑小游戲源代碼 完整代碼下載地址:Python版基于

    2024年02月11日
    瀏覽(93)
  • Python版經(jīng)典小游戲憤怒的小鳥(niǎo)源代碼,基于pygame+pymunk

    Python版經(jīng)典小游戲憤怒的小鳥(niǎo)源代碼,基于pygame+pymunk

    Python版經(jīng)典小游戲憤怒的小鳥(niǎo)源代碼,基于pygame+pymunk 程序依賴:pygame 2.0.1, pymunk 5.5.0 直接運(yùn)行main.py 完整代碼下載地址:Python版經(jīng)典小游戲憤怒的小鳥(niǎo)源代碼 tool.py 完整代碼下載地址:Python版經(jīng)典小游戲憤怒的小鳥(niǎo)源代碼

    2024年02月16日
    瀏覽(103)
  • 使用Python+pygame實(shí)現(xiàn)貪吃蛇小游戲

    使用Python+pygame實(shí)現(xiàn)貪吃蛇小游戲

    使用第三方庫(kù)pygame,關(guān)于Python中pygame游戲模塊的安裝使用可見(jiàn)?https://blog.csdn.net/cnds123/article/details/119514520 給出兩種實(shí)現(xiàn)。 第一種 運(yùn)行效果如下: 游戲源碼如下: 第二種 就不給出運(yùn)行效果圖了,你可以運(yùn)行看看。 下面給出另一種實(shí)現(xiàn)源碼: OK!?

    2024年01月16日
    瀏覽(55)
  • 強(qiáng)化學(xué)習(xí)Agent系列(一)——PyGame游戲編程,Python 貪吃蛇制作實(shí)戰(zhàn)教學(xué)

    強(qiáng)化學(xué)習(xí)Agent系列(一)——PyGame游戲編程,Python 貪吃蛇制作實(shí)戰(zhàn)教學(xué)

    大家好,未來(lái)的開(kāi)發(fā)者們請(qǐng)上座 隨著人工智能的發(fā)展,強(qiáng)化學(xué)習(xí)基本會(huì)再次來(lái)到人們眼前,遂想制作一下相關(guān)的教程。強(qiáng)化學(xué)習(xí)第一步基本離不開(kāi)虛擬環(huán)境的搭建,下面用大家耳熟能詳?shù)呢澇陨哂螒驗(yàn)榛A(chǔ),制作一個(gè)Agent,完成對(duì)這個(gè)游戲的絕殺。 萬(wàn)里長(zhǎng)城第一步:用pytho

    2024年01月21日
    瀏覽(29)

覺(jué)得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請(qǐng)作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包