python中的循环不更新

发布于 2025-01-25 20:05:15 字数 990 浏览 2 评论 0原文

看到即将到来的数字,

while keyboard.is_pressed('q') == False:

if pyautogui.locateCenterOnScreen('Pipe.png', confidence = 0.7) != None:
    pipePos = pyautogui.locateCenterOnScreen('Pipe.png', confidence = 0.7)
    PipeYpos = pipePos.y
    print(pipePos)
    print("I can see it The Pipe")
    t = 1
else:
    print("I am unable to see it The Pipe")
    t = 0
    
if pyautogui.locateCenterOnScreen('BirdV2.png', confidence = 0.5) != None:
    birdpos = pyautogui.locateCenterOnScreen('BirdV2.png', confidence = 0.5)
    birdyPos = birdpos.y
    print(birdpos)
    print("I can see it The Bird")
    t = 1
else:
    print("I am unable to see it The BIRD")
    t = 0

当循环获得birdypos> = pipeypos时,我的时循环不更新,在这里

while birdyPos >= PipeYpos and keyboard.is_pressed('q') == False and t == 1 and PipeYpos != 0:
    print("Pipe > bird")
    click(1384 ,1235)
    birdyPos = 0
    PipeYpos = 0

它不会忘记

它会继续前进 我希望它停止并确保数字正确并再次循环

my while loop not updating and see the up coming numbers

while keyboard.is_pressed('q') == False:

if pyautogui.locateCenterOnScreen('Pipe.png', confidence = 0.7) != None:
    pipePos = pyautogui.locateCenterOnScreen('Pipe.png', confidence = 0.7)
    PipeYpos = pipePos.y
    print(pipePos)
    print("I can see it The Pipe")
    t = 1
else:
    print("I am unable to see it The Pipe")
    t = 0
    
if pyautogui.locateCenterOnScreen('BirdV2.png', confidence = 0.5) != None:
    birdpos = pyautogui.locateCenterOnScreen('BirdV2.png', confidence = 0.5)
    birdyPos = birdpos.y
    print(birdpos)
    print("I can see it The Bird")
    t = 1
else:
    print("I am unable to see it The BIRD")
    t = 0

here is the problem

while birdyPos >= PipeYpos and keyboard.is_pressed('q') == False and t == 1 and PipeYpos != 0:
    print("Pipe > bird")
    click(1384 ,1235)
    birdyPos = 0
    PipeYpos = 0

when the loop get the birdyPos >= PipeYpos it wouldn't forget

it will keep going
i want it to stop and make sure the numbers are correct and looping again

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文