Baekalfen / PyBoy

Game Boy emulator written in Python
Other
4.64k stars 476 forks source link

input not working #308

Closed FunnyIvri closed 9 months ago

FunnyIvri commented 9 months ago

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()```
Baekalfen commented 9 months ago

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

FunnyIvri commented 9 months ago

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()
Baekalfen commented 9 months ago

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

FunnyIvri commented 9 months ago

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)