最近用python写了一个可以模拟原神抽卡的程序,但是写到一半烂尾了,就希望有大佬能帮忙继续完成,目前才完成了播放视频(没有声音),原神抽卡界面卡池的切换,整个程序没有用一个button,全部的按键用的都是检测鼠标点击位置,放几张图片,代码和需要用到的视频都放在下面了,图片的话可以从游戏中截图。





这是代码
import tkinter as tk
import cv2
from PIL import Image, ImageTk
import random
video_playing = False
count = 1
c=0
def handle_click(event):
global count
x, y = event.x, event.y
print(f"鼠标左键点击了一次坐标是:x={x} y={y}")
if 407 < x < 492 and 16 < y < 53:
show_image('aaa1.gif')
count = 1
elif 507 < x < 591 and 17 < y < 54:
show_image('aaa2.gif')
count = 2
elif 607 < x < 691 and 17 < y < 54:
show_image('aaa3.gif')
count = 3
elif 300 < x < 400 and 17 < y < 54:
show_image('aaa.gif')
count = 4
elif 613 < x < 761 and 542 < y < 579:
print("祈愿一次")
play_single_wish(count)
if count==1:
play_video('aaa1.gif')
elif count==2:
play_video('aaa2.gif')
elif count==3:
play_video('aaa3.gif')
elif count==4:
play_video('aaa.gif')
elif 810 < x < 950 and 542 < y < 579:
print("祈愿十次")
play_ten_wish()
if count==1:
play_video('aaa1.gif')
elif count==2:
play_video('aaa2.gif')
elif count==3:
play_video('aaa3.gif')
elif count==4:
play_video('aaa.gif')
def show_image(image_path):
global current_image_label
new_image = tk.PhotoImage(file=image_path)
current_image_label.config(image=new_image)
current_image_label.image = new_image
def play_single_wish(count):
video_path = get_video_path(count)
play_video(video_path)
def play_ten_wish():
global c
l=random.randint(1,10)
print(l)
if l==1:
play_video("十连出金.mp4")
c=0
print(c)
elif c==80:
play_video("十连出金.mp4")
c=0
else:
play_video("十连出紫.mp4")
c=c+10
print(c)
def get_video_path(count):
global c
a = random.randint(0, 1000)
print(a)
b=0
if a <= 6:
return "单抽出金.mp4"
c=0
elif a <= 51:
return "单抽出紫.mp4"
b=0
c=c+1
print(b)
print(c)
elif b==9:
return "单抽出紫.mp4"
b=0
c=c+1
elif c==89:
return "单抽出金.mp4"
c=0
else:
return "单抽出蓝.mp4"
b=b+1
c=c+1
print(b)
print(c)
def play_video(video_path):
global video_playing
video = cv2.VideoCapture(video_path)
video_playing = True
while video_playing:
res, img = video.read()
if res:
img = cv2.resize(img, (1000, 600))
img_rgb = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
img_pil = Image.fromarray(img_rgb)
img_tk = ImageTk.PhotoImage(img_pil)
current_image_label.config(image=img_tk)
current_image_label.image = img_tk
current_image_label.update()
else:
video.set(cv2.CAP_PROP_POS_FRAMES, 0)
video_playing = False
root = tk.Tk()
root.title('原神抽卡v4.6')
root.geometry('1000x600')
current_image_label = tk.Label(root)
current_image_label.pack()
current_image_path = 'aaa.gif'
initial_image = tk.PhotoImage(file=current_image_path)
current_image_label.config(image=initial_image)
current_image_label.bind("<Button-1>", handle_click)
root.mainloop()
https://pan.baidu.com/s/1EKkG3SFzlHebz5SaM_akHw
提取码:1111
897

被折叠的 条评论
为什么被折叠?



