简介
最近B站给我推的骗子酒馆有点多,居然还有真人版,于是!🤓👆🏼
代码
python"># -*- coding: utf-8 -*-
# Environment PyCharm
# File_name player |User Pfolg
# 2024/10/28 19:17
import ctypes
import random
import threading
import time
import tkinter as tk
from tkinter import ttk, simpledialog
import pygameico = ".\\source\\death.ico"
name = "搏命左轮"
loadBullets = ".\\source\\add.mp3"
null = ".\\source\\null.mp3"
shoot = ".\\source\\shoot.mp3"
ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID(name)# 生成子弹位置def makeLocation(array: list):index = random.randint(0, len(array) - 1)array[index] = 1return arraybullets = [0 for i in range(6)]
bullets = makeLocation(bullets)# print(bullets)
pygame.mixer.init() # 初始化pygame的声音模块
# 加载音乐
music1 = pygame.mixer.Sound(loadBullets)
music2 = pygame.mixer.Sound(null)
music3 = pygame.mixer.Sound(shoot)def delayMusic1():lb = ttk.Label(window, text="装弹中……")lb.place(relx=.4, rely=.45)time.sleep(1)music1.play()lb.place_forget()main_btu.place(relx=.38, rely=.8)def showStatus():global countif count < 6:btus[count].config(state="normal")if bullets[count]:btus[count].config(background="#f44747")btus[count].config(state="disabled")window.config(background=btus[count]["background"])main_btu.config(background=btus[count]["background"])playerLb.config(background=btus[count]["background"])count = 10music3.play()else:btus[count].config(background="#6ad4b4")btus[count].config(state="disabled")music2.play()count += 1def changName(e):# 弹出问答窗口并获取用户输入new_name = simpledialog.askstring(title="更改玩家昵称", prompt="请输入新的昵称:")if new_name:player_name.set(new_name)if __name__ == '__main__':# 窗口初始设定window = tk.Tk()window.title(name)sw, sh = window.winfo_screenwidth(), window.winfo_screenheight()ww, wh = int(sw / 5), int(sh / 4)window.geometry(f"{ww}x{wh}+{int(sw / 4)}+{int(sh / 4)}")window.resizable(False, False)window.iconbitmap(ico)window.wm_iconbitmap(ico)bullets_btu = [tk.IntVar() for _ in range(len(bullets))]for i in range(len(bullets)):bullets_btu[i].set(bullets[i])# print(bullets_btu[i].get())btus = [tk.Button(window, background="#e5c07b", width=3, relief="groove", text="", state="disabled",)for _ in range(len(bullets_btu))]for i in range(len(btus)):btus[i].place(relx=.08 + i * .15, rely=.2)count = 0main_btu = tk.Button(window, text="扣动扳机", command=showStatus)player_name = tk.StringVar()player_name.set("Player")playerLb = ttk.Label(window, textvariable=player_name, foreground="#c575a9", font=("微软雅黑 bold", 10),cursor="hand2")playerLb.bind("<Button-1>", changName)playerLb.place(relx=.4, rely=.6)threading.Thread(target=delayMusic1).start()window.mainloop()
演示
资源
我在C站上传的资源未通过审核,下面是唯一渠道,你也可以改代码
Release 左轮搏命 · Pfolg/Pfolg_Source (github.com)https://github.com/Pfolg/Pfolg_Source/releases/tag/v.Max.ZLBM