Skip to content

Pyaudiogame Menus #2

@tbreitenfeldt

Description

@tbreitenfeldt

Hi, my name is TJ and I have been trying to learn how to use your pyaudiogame library. I have been trying to create menus using your library, but some strange things are happening.

When I create a menu say as a main menu for right when the game loads I am getting a loop of Jaws repeating the first option of the menu over and over. When I change to the next option by using the down arrow the program will read the current option then go back to repeating the first option.
I then tried running a condition so that if "m" open the menu. All this does is read the first menu option.

Here is my code that I am using:

import pyaudiogame
from pyaudiogame.ui.menus import Menu

def spk(accessibleOutput):
spk = pyaudiogame.speech.speak(accessibleOutput)

class MyApp(pyaudiogame.App):
def set_defaults(self):
self.exit_key = 2

def logic(self, actions):
    """this is using the conditional, but I also would like to know why Jaws is stuck in a loop when menu loads first"""
    key = actions["key"]
    if key == "m":
        m = Menu(options=["option1", "option2"], title="Main Menu")
        m.run(actions)
    if key == "space":
        spk("this is a test")

MyApp("hello World").run()

I was also wondering, it isn't clear how to connect a option in the menu to an action. I am guessing that I could say:
if except == True:
but I am not sure if that is correct.

Hope you can help.

Thanks,

TJ Breitenfeldt

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions