Baekalfen/PyBoy

input not working

Closed this issue · 4 comments

for some reason input isnt working
heres my code:

from pyboy import PyBoy, WindowEvent

gameBoy = PyBoy('test.gb')
gameBoy.set_emulation_speed(1)
while True:
    gameBoy.tick()
    gameBoy.send_input(WindowEvent.PRESS_BUTTON_START)
    gameBoy.tick()```

You probably need to release the button too: gameBoy.send_input(WindowEvent.RELEASE_BUTTON_START)

this didnt work :(

You probably need to release the button too: gameBoy.send_input(WindowEvent.RELEASE_BUTTON_START)

from pyboy import PyBoy, WindowEvent

gameBoy = PyBoy('test.gb')
gameBoy.set_emulation_speed(1)
while True:
    gameBoy.tick()
    gameBoy.send_input(WindowEvent.PRESS_BUTTON_START)
    gameBoy.tick()
    gameBoy.send_input(WindowEvent.RELEASE_BUTTON_START)
    gameBoy.tick()

Your game might not read the input every frame. Try adding 5 calls to tick between each input.

Otherwise, come and get help on the Discord server. I try to keep the issues here on GitHub about bugs in PyBoy, rather than troubleshooting https://discord.gg/Zrf2nyH

thanks this worked!
could have never guessed that was the issue!

edit: i removed most of the ticks and now it works?
if anyone ever has a similar problem this is the code that worked for me:

from pyboy import PyBoy, WindowEvent

gameBoy = PyBoy('test.gb')
gameBoy.set_emulation_speed(1)
while not gameBoy.tick():
    gameBoy.send_input(WindowEvent.PRESS_BUTTON_START)
    gameBoy.tick()
    gameBoy.send_input(WindowEvent.RELEASE_BUTTON_START)