Baekalfen / PyBoy

Game Boy emulator written in Python
Other
4.57k stars 472 forks source link

input not working #308

Closed FunnyIvri closed 6 months ago

FunnyIvri commented 6 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 6 months ago

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

FunnyIvri commented 6 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 6 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 6 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)