Пример #1
0
def main():
    #Show window
    lucia.show_window("1d Sound Example.")
    #Create the player
    listener = player()
    #Play a sound on a 1d grid.
    #Must use 2d playing function in order for the sound to actually pan
    sound_pool.play_2d("ding.ogg", listener.x, 0, 0, 0, True)
    while 1:
        #Allow lucia to update it's internal queues and events
        lucia.process_events()
        #Check for key presses
        if lucia.key_pressed(lucia.K_LEFT):
            #Move the player 1 step to the left
            listener.x -= 1
            #Update the sound pool with the new player position
            sound_pool.update_listener_1d(listener.x)
        elif lucia.key_pressed(lucia.K_RIGHT):
            #Move the player 1 step to the right
            listener.x += 1
            #Update the sound pool with the new player position
            sound_pool.update_listener_1d(listener.x)
        elif lucia.key_pressed(lucia.K_c):
            #Output x coordinate
            lucia.output.output(str(listener.x))
        elif lucia.key_pressed(lucia.K_ESCAPE):
            #Exit
            lucia.quit()
            sys.exit()
        #Sleep for 2 milliseconds
        lucia.pygame.time.wait(2)
Пример #2
0
    def run(self, intro, isfile=False):
        # Overrides the run function in menu

        try:
            self._running = True

            self.__play__("open")
            if self._title: lucia.output.speak(self._title)
            if not isfile:
                lucia.output.speak(intro, False)
            else:
                intro = self.__load__(intro)
                intro.play()

            while self._running:
                time.sleep(0.005)
                lucia.process_events()

                if lucia.key_pressed(lucia.K_DOWN) and not self.orientation:
                    self.__change_position__(1)
                elif lucia.key_pressed(lucia.K_UP) and not self.orientation:
                    self.__change_position__(-1)
                elif lucia.key_pressed(lucia.K_LEFT) and self.orientation:
                    self.__change_position__(-1)
                elif lucia.key_pressed(lucia.K_RIGHT) and self.orientation:
                    self.__change_position__(1)
                elif lucia.key_pressed(lucia.K_RETURN):
                    return self.__return_selection__()
        except Exception:
            self._running = False
            lucia.logger.exception(e)
Пример #3
0
    def run(self, intro, isfile=False):
        try:
            self._running = True

            self.__play__("open")
            if self._title: lucia.output.speak(self._title)
            if not isfile:
                lucia.output.speak(intro, False)
            else:
                intro = self.__load__(intro)
                intro.volume = self._volume
                print(intro.volume)
                intro.play()

            while self._running:
                time.sleep(0.005)  # Be kind to processors
                lucia.process_events()

                if lucia.key_pressed(lucia.K_UP):
                    self.__change_position__(1, intro, isfile)
                elif lucia.key_pressed(lucia.K_DOWN):
                    self.__change_position__(-1, intro, isfile)
                elif lucia.key_pressed(lucia.K_RETURN):
                    self.__play__("enter")
                    self._running = False
                    return True
            print("end")
        except Exception as e:
            lucia.logger.exception(e)
        else:
            return False
Пример #4
0
def MainLoop():
    global x, oldX, y, oldY, direction, oldDirection
    timer = utils.Timer(
    )  # Prevents the user from walking faster than the sound can play. You're not the Flash.
    WALK_SPEED = 300  # milliseconds
    timer.elapsed = WALK_SPEED  # So the user can walk straight away
    xAxis, yAxis = (0, 0)

    while True:
        time.sleep(0.005)  # Be kind to processors
        lucia.process_events()

        # Set the movement coordinate changes
        if lucia.key_down(lucia.K_UP): yAxis = 1
        if lucia.key_down(lucia.K_DOWN): yAxis = -1
        if lucia.key_up(lucia.K_UP) and lucia.key_up(lucia.K_DOWN): yAxis = 0
        if lucia.key_down(lucia.K_RIGHT): xAxis = 1
        if lucia.key_down(lucia.K_LEFT): xAxis = -1
        if lucia.key_up(lucia.K_RIGHT) and lucia.key_up(lucia.K_LEFT):
            xAxis = 0

        if (not xAxis == 0 or not yAxis == 0) and timer.elapsed >= WALK_SPEED:
            timer.restart()

            # Set the direction
            if xAxis == 0 and yAxis == 1: direction = 90
            elif xAxis == 1 and yAxis == 1: direction = 45
            elif xAxis == 1 and yAxis == 0: direction = 0
            elif xAxis == 1 and yAxis == -1: direction = 315
            elif xAxis == 0 and yAxis == -1: direction = 270
            elif xAxis == -1 and yAxis == -1: direction = 225
            elif xAxis == -1 and yAxis == 0: direction = 180
            elif xAxis == -1 and yAxis == 1: direction = 135

            # set new coordinates
            x, y = (x + xAxis, y + yAxis)

            # Update the listener
            pool.update_listener_3d(x, y, 0, direction)

            if not direction == oldDirection:
                squeak.play()
                oldDirection = direction

            if (not oldX == x) or (not oldY == y):
                step.play()
                oldX, oldY = (x, y)

        if lucia.key_pressed(lucia.K_q):
            break
        elif lucia.key_pressed(lucia.K_c):
            lucia.output.speak(
                f"you are at x: {x}, y: {y}, facing {textDirections[direction]}"
            )
        elif lucia.key_pressed(lucia.K_z):
            x = 0
            y = 0
            direction = 90
            pool.update_listener_3d(x, y, 0, direction)
Пример #5
0
def main():
    #Show window
    lucia.show_window("Speaking Example.")
    while 1:
        #Allow lucia to update it's internal queues and events
        lucia.process_events()
        #Check for key presses
        if lucia.key_pressed(lucia.K_SPACE):
            lucia.output.output("Hello, world!")
        if lucia.key_pressed(lucia.K_RETURN):
            lucia.output.output("Good bye, world!")
            #Account for slower screen readers
            lucia.pygame.time.wait(1500)
            lucia.quit()
            sys.exit()
        #Sleep for 2 milliseconds
        lucia.pygame.time.wait(2)
Пример #6
0
def main():
    #Show window
    lucia.show_window("2d Sound Example.")
    #Create the player
    listener = player()
    #Play a sound on a 2d grid.
    sound_pool.play_2d("ding.ogg", listener.x, listener.y, 0, 0, True)
    while 1:
        #Allow lucia to update it's internal queues and events
        lucia.process_events()
        #Check for key presses
        if lucia.key_pressed(lucia.K_LEFT):
            #Move the player 1 step to the left
            move_object(listener, 3)
        elif lucia.key_pressed(lucia.K_RIGHT):
            #Move the player 1 step to the right
            move_object(listener, 1)
        elif lucia.key_pressed(lucia.K_UP):
            #Move the player one step forward
            move_object(listener, 0)
        elif lucia.key_pressed(lucia.K_DOWN):
            #Move the player one step backwards
            move_object(listener, 2)
        elif lucia.key_pressed(lucia.K_c):
            #Output coordinates
            lucia.output.output(str(listener.x) + ", " + str(listener.y))
        elif lucia.key_pressed(lucia.K_ESCAPE):
            #Exit
            lucia.quit()
            sys.exit()
        #Sleep for 2 milliseconds
        lucia.pygame.time.wait(2)
Пример #7
0
def main():
    #Show window
    lucia.show_window("Keyboard Example.")
    while 1:
        #Allow lucia to update it's internal queues and events
        lucia.process_events()
        #Check for key presses
        #Typically this should be done in a separate function, but we will keep this as simple as possible
        if lucia.key_pressed(lucia.K_SPACE):
            print("You pressed space!")
            sys.exit()
        #Check for key holds
        if lucia.key_down(lucia.K_RETURN):
            print("You held enter!")
            lucia.quit()
            sys.exit()
        #Sleep for 2 milliseconds
        lucia.pygame.time.wait(2)
Пример #8
0
    def run(self, intro="", isfile=False):
        """ Displayes the menu and waits for a selection

		This function blocks until the menu is closed, either by selecting an item or pressing escape.
		Available controls are up/down arrows, enter, and escape. Wrapping is not supported.

		args:
		        intro (str, optional): Some brief instructions spoken after the menu title.
		    isfile (bool, optional): Set to True if the intro is the name of an audio file that contains the intro

		returns:
		        Either the item name, its value, or -1 if escape is allowed.
		"""

        try:
            self._running = True

            self.__play__("open")
            if self._title: lucia.output.speak(self._title)
            if intro:
                if not isfile:
                    lucia.output.speak(intro, False)
                else:
                    intro = self.__load__(intro)
                    intro.play()

            while self._running:
                time.sleep(0.005)  # Be kind to processors
                lucia.process_events()

                if callable(self._callback):
                    self._callback(self)

                if lucia.key_pressed(lucia.K_ESCAPE) and self.exit_on_escape:
                    self._running = False
                    self.__play__(self._sounds["cancel"])
                    return "-1"
                elif lucia.key_pressed(lucia.K_DOWN):
                    self.__change_position__(1)
                elif lucia.key_pressed(lucia.K_UP):
                    self.__change_position__(-1)
                elif lucia.key_pressed(lucia.K_LEFT) and callable(
                        self._items[self._item_position].slider_function):
                    self._items[self._item_position].slider_function(self, -1)
                elif lucia.key_pressed(lucia.K_RIGHT) and callable(
                        self._items[self._item_position].slider_function):
                    self._items[self._item_position].slider_function(self, 1)
                elif lucia.key_pressed(lucia.K_SPACE) and self._items[
                        self._item_position].can_be_toggled:
                    self.__change_toggle__()
                elif (lucia.key_pressed(lucia.K_LSHIFT)
                      or lucia.key_pressed(lucia.K_RSHIFT)
                      ) and self._items[self._item_position].enter_value:
                    self.__get_input__()
                elif lucia.key_pressed(lucia.K_RETURN):
                    self._running = False
                    return self.__return_selection__()
        except Exception as e:
            lucia.logger.exception(e)
        finally:
            self._running = False
Пример #9
0
def MainLoop():
    global x, y, width, height
    timer = utils.Timer(
    )  # Prevents the user from walking faster than the sound can play. You're not the Flash.
    WALK_SPEED = 300  # milliseconds
    timer.elapsed = WALK_SPEED  # So the user can walk straight away
    xAxis, yAxis = (0, 0)

    # Define the shapes
    # Each vertice followed by a fill value (True fills the shape in, False plots only the outline)
    sky = utils.Rectangle(0, 29, 29, 19,
                          True)  # Top left corner to bottom left corner
    ground = utils.Rectangle(0, 18, 29, 0, True)
    sun = utils.Circle(4, 25, 3,
                       True)  # The center point followed by the radius
    roof = utils.Triangle(11, 22, 25, 22, 18, 27,
                          True)  # The three corner vertices of the triangle
    house = utils.Rectangle(13, 21, 23, 13, True)

    # Draw each shape one by one
    for v in sky:
        field[v[0]][v[1]] = "blue"
    for v in ground:
        field[v[0]][v[1]] = "green"
    for v in sun:
        field[v[0]][v[1]] = "yellow"
    for v in roof:
        field[v[0]][v[1]] = "red"
    for v in house:
        field[v[0]][v[1]] = "brown"

    # Main action loop
    while True:
        time.sleep(0.005)  # Be kind to processors
        lucia.process_events()

        # Set the movement coordinate changes
        if lucia.key_down(lucia.K_UP): yAxis = 1
        if lucia.key_down(lucia.K_DOWN): yAxis = -1
        if lucia.key_up(lucia.K_UP) and lucia.key_up(lucia.K_DOWN): yAxis = 0
        if lucia.key_down(lucia.K_RIGHT): xAxis = 1
        if lucia.key_down(lucia.K_LEFT): xAxis = -1
        if lucia.key_up(lucia.K_RIGHT) and lucia.key_up(lucia.K_LEFT):
            xAxis = 0

        # Only do something if the keys are pressed and slow down any change based on the speed of movement
        if (not xAxis == 0 or not yAxis == 0) and timer.elapsed >= WALK_SPEED:
            timer.restart()

            # set new coordinates
            if x + xAxis >= 0 and y + yAxis >= 0 and x + xAxis < width and y + yAxis < height:  # Check to be sure the coordinates are within the field
                x, y = (x + xAxis, y + yAxis)
                lucia.output.speak(str(field[x][y]))
            else:
                lucia.output.speak("bump")

        # Some other function keys (These are not restricted by the walk speed)
        if lucia.key_pressed(lucia.K_q):  # Quit the program
            break
        elif lucia.key_pressed(lucia.K_z):  # Speak the coordinates of the user
            lucia.output.speak(f"you are at x: {x}, y: {y}")
Пример #10
0
def callback_test(menu):
    print("hello world")


menu = lucia.ui.Menu()
menu.add_item_tts("Hello")
menu.add_item_tts("world")
menu.add_item_tts("this")
menu.add_item_tts("is")
menu.add_item_tts("a")
menu.add_item_tts("test")
menu.set_callback(callback_test)
result = menu.run("Please select something")
print(str(result))

username = lucia.ui.VirtualInput("Enter a username")
result = username.run()
print(f"username: {result}")
password = lucia.ui.VirtualInput("Enter a password", True)
result = password.run()
print(f"password: {result}")

while True:
    lucia.process_events()
    if lucia.key_pressed(lucia.K_a):
        lucia.output.output("Hey.")
    if lucia.key_pressed(lucia.K_q):
        break

lucia.quit()
Пример #11
0
    def run(self, intro="", isfile=False):
        """ Displayes the menu and waits for a selection

		This function blocks until the menu is closed, either by selecting an item or pressing escape.
		Available controls are up/down arrows, tab and shift + tab, ctrl + up and down, space and enter, and escape.

		args:
		        intro (str, optional): Some brief instructions spoken after the menu title.
		    isfile (bool, optional): Set to True if the intro is the name of an audio file that contains the intro

		returns:
		        The name of a file or directory
		"""

        try:
            self._running = True

            self.__play__("open")
            if self._title: lucia.output.speak(self._title)
            if intro:
                if not isfile:
                    lucia.output.speak(intro, False)
                else:
                    intro = self.__load__(intro)
                    intro.play()

            while self._running:
                time.sleep(0.005)  # Be kind to processors
                lucia.process_events()

                if callable(self._callback):
                    self._callback(self)

                if lucia.key_pressed(lucia.K_ESCAPE) and self.exit_on_escape:
                    self._running = False
                    self.__play__("cancel")
                    return "-1"
                elif lucia.key_pressed(lucia.K_DOWN):
                    if lucia.key_down(lucia.K_LALT) or lucia.key_down(
                            lucia.K_RALT):
                        self.__forward__()
                    else:
                        self.__change_position__(1)
                elif lucia.key_pressed(lucia.K_UP):
                    if lucia.key_down(lucia.K_LALT) or lucia.key_down(
                            lucia.K_RALT):
                        self.__back__()
                    else:
                        self.__change_position__(-1)
                if lucia.key_pressed(lucia.K_TAB):
                    if lucia.key_down(lucia.K_RSHIFT) or lucia.key_down(
                            lucia.K_LSHIFT):
                        self.__change_tab__(-1)
                    else:
                        self.__change_tab__(1)
                elif lucia.key_pressed(lucia.K_RETURN) or lucia.key_pressed(
                        lucia.K_SPACE):
                    result = self.__return_selection__()
                    if result:
                        self._running = False
                        return result
        except Exception as e:
            lucia.logger.exception(e)
        finally:
            self._running = False
Пример #12
0
pool = lucia.audio_backend.SoundPool()
player = lucia.utils.rotation.Vector()
direction = 0

s = pool.play_3d(os.path.join(os.getcwd(), "sounds", "audio.ogg"),
                 5,
                 5,
                 0,
                 10,
                 10,
                 0,
                 looping=True)

while True:
    lucia.process_events()
    if lucia.key_pressed(lucia.K_LEFT):
        direction = lucia.utils.rotation.turnleft(direction, 10)
    if lucia.key_pressed(lucia.K_RIGHT):
        direction = lucia.utils.rotation.turnright(direction, 10)
    if lucia.key_pressed(lucia.K_w):
        player = lucia.utils.rotation.move((player.x, player.y, player.z),
                                           direction)
    if lucia.key_pressed(lucia.K_a):
        player = lucia.utils.rotation.move((player.x, player.y, player.z),
                                           direction - 90)
    if lucia.key_pressed(lucia.K_s):
        player = lucia.utils.rotation.move((player.x, player.y, player.z),
                                           direction + 180)
    if lucia.key_pressed(lucia.K_d):
        player = lucia.utils.rotation.move((player.x, player.y, player.z),
                                           direction + 90)
Пример #13
0
    def run(self, intro="select an option", interrupt=True):
        """presents this menu to the user.
		
		This function blocks until the menu is closed, either by selecting an item or pressing escape.
		Available controls are up/down arrows, enter, and escape. Wrapping is not supported.
		
		args:
		    intro (str, optional): The text that will be spoken when the menu is presented, this will occur at the same time as the open sound. Default is 'select an option'
		    interrupt (bool, optional): Determines if speech is interrupted when it is queued to be spoken. For your sanity, this should always be True. Defaults to True.
		
		returns:
		    str if an option was selected, containing the option's internal name. -1 if escape was pressed.
		"""
        self.count = 0
        self.running = True
        try:
            self.music.play()
        except:
            pass
        try:
            self.open_sound.play()
        except:
            pass
        if intro != "":
            self.speechMethod.speak(intro, interrupt)
        while self.running and lucia.running:
            lucia.process_events()
            if callable(self.callback):
                self.callback(self)
            time.sleep(0.005)
            if lucia.key_pressed(lucia.K_ESCAPE):
                try:
                    self.enter_sound.play()
                except:
                    pass
                try:
                    self.music.stop()
                except:  # thrown if no music was specified.
                    pass
                return "-1"
            if lucia.key_pressed(lucia.K_DOWN):
                if self.count < len(self.items) - 1:
                    self.count = self.count + 1
                    try:
                        self.scroll_sound.play()
                    except:
                        pass
                else:
                    try:
                        self.border_sound.play()
                    except:
                        pass
                self.speechMethod.speak(
                    list(self.items)[self.count], self.shouldInterrupt)
            if lucia.key_pressed(lucia.K_UP):
                if self.count > 0:
                    self.count = self.count - 1
                    try:
                        self.scroll_sound.play()
                    except:
                        pass
                else:
                    try:
                        self.border_sound.play()
                    except:
                        pass
                self.speechMethod.speak(
                    list(self.items)[self.count], self.shouldInterrupt)
            if lucia.key_pressed(lucia.K_RETURN):
                try:
                    self.enter_sound.play()
                except:
                    pass
                self.running = False
                try:
                    self.music.stop()
                except:  # thrown if no music was selected
                    pass
        return self.items[list(self.items)[self.count]]
Пример #14
0
 def loop(self):
     while 1:
         time.sleep(0.005)
         try:
             lucia.process_events()
             if callable(self.callback):
                 self.callback()
             if lucia.key_pressed(lucia.K_RETURN):
                 if self.items[self.itempos].can_return:
                     if self.entersound != "":
                         source = self.pool.play_stationary(self.entersound)
                     list_values = []
                     if self.items[self.itempos].event == CANCELEVENT:
                         if callable(
                                 self.items[self.itempos].item_function):
                             self.items[self.itempos].item_function()
                         return list_values
                     #returns results as a list of dictionaries. The currently focused item returns as the first item in the list
                     for x in self.items:
                         if x.name != self.items[self.itempos].name:
                             list_values.append({
                                 "name":
                                 x.name,
                                 "value":
                                 x.value,
                                 "toggle_value":
                                 x.toggle_value
                             })
                     list_values.insert(
                         0,
                         {
                             "name":
                             self.items[self.itempos].name,
                             "value":
                             self.items[self.itempos].value,
                             "toggle_value":
                             self.items[self.itempos].toggle_value,
                         },
                     )
                     if callable(self.items[self.itempos].item_function):
                         self.items[self.itempos].item_function()
                     else:
                         return list_values
             elif lucia.key_pressed(lucia.K_UP):
                 if self.itempos > 0:
                     self.itempos -= 1
                     if self.clicksound != "":
                         clicksound = self.pool.play_stationary(
                             self.clicksound)
                     if callable(self.on_index_change):
                         self.on_index_change()
                     if callable(self.items[self.itempos].on_focus):
                         self.items[self.itempos].on_focus(self)
                     if (self.items[self.itempos].has_value == False
                             and self.items[self.itempos].can_be_toggled
                             == False):
                         lucia.output.speak(self.items[self.itempos].name)
                     elif (self.items[self.itempos].has_value
                           and self.items[self.itempos].can_be_toggled
                           == False):
                         lucia.output.speak(
                             self.items[self.itempos].name + ": " +
                             str(self.items[self.itempos].value) +
                             ". Press left shift or right shift to change this item's value"
                         )
                     elif (self.items[self.itempos].has_value == False
                           and self.items[self.itempos].can_be_toggled):
                         if self.items[self.itempos].toggle_value == True:
                             lucia.output.speak(
                                 self.items[self.itempos].name + ": " +
                                 self.items[self.itempos].on_value + " " +
                                 self.items[
                                     self.itempos].toggle_item_message +
                                 " " + self.items[self.itempos].off_value)
                         else:
                             lucia.output.speak(
                                 self.items[self.itempos].name + ": " +
                                 self.items[self.itempos].off_value + " " +
                                 self.items[
                                     self.itempos].toggle_item_message +
                                 " " + self.items[self.itempos].on_value)
                     elif (self.items[self.itempos].has_value
                           and self.items[self.itempos].can_be_toggled):
                         speakstr = (self.items[self.itempos].name +
                                     ". Value: " +
                                     str(self.items[self.itempos].value))
                         if self.items[self.itempos].toggle_value == True:
                             speakstr += ". Switch: " + self.items[
                                 self.itempos].on_value
                         else:
                             speakstr += ". Switch: " + self.items[
                                 self.itempos].off_value
                         lucia.output.speak(
                             speakstr +
                             ". Press left shift or right shift to change this item's value. "
                             + self.items[self.itempos].toggle_item_message)
             elif lucia.key_pressed(lucia.K_DOWN):
                 if self.itempos < len(self.items) - 1:
                     self.itempos += 1
                     if self.clicksound != "":
                         clicksound = self.pool.play_stationary(
                             self.clicksound)
                     if self.items[self.itempos].on_focus != None:
                         self.items[self.itempos].on_focus()
                     if self.on_index_change != None:
                         self.on_index_change()
                     if (self.items[self.itempos].has_value == False
                             and self.items[self.itempos].can_be_toggled
                             == False):
                         lucia.output.speak(self.items[self.itempos].name)
                     elif (self.items[self.itempos].has_value
                           and self.items[self.itempos].can_be_toggled
                           == False):
                         lucia.output.speak(
                             self.items[self.itempos].name + ": " +
                             str(self.items[self.itempos].value) +
                             ". Press left shift or right shift to change this item's value"
                         )
                     elif (self.items[self.itempos].has_value == False
                           and self.items[self.itempos].can_be_toggled):
                         if self.items[self.itempos].toggle_value == True:
                             lucia.output.speak(
                                 self.items[self.itempos].name + ": " +
                                 self.items[self.itempos].on_value + " " +
                                 self.items[
                                     self.itempos].toggle_item_message +
                                 " " + self.items[self.itempos].off_value)
                         else:
                             lucia.output.speak(
                                 self.items[self.itempos].name + ": " +
                                 self.items[self.itempos].off_value + " " +
                                 self.items[
                                     self.itempos].toggle_item_message +
                                 " " + self.items[self.itempos].on_value)
                     elif (self.items[self.itempos].has_value
                           and self.items[self.itempos].can_be_toggled):
                         speakstr = (self.items[self.itempos].name +
                                     ". Value: " +
                                     str(self.items[self.itempos].value))
                         if self.items[self.itempos].toggle_value == True:
                             speakstr += ". Switch: " + self.items[
                                 self.itempos].on_value
                         else:
                             speakstr += ". Switch: " + self.items[
                                 self.itempos].off_value
                         lucia.output.speak(
                             speakstr +
                             ". Press left shift or right shift to change this item's value. "
                             + self.items[self.itempos].toggle_item_message)
             elif lucia.key_pressed(lucia.K_SPACE):
                 if self.itempos > -1 and self.itempos < len(self.items):
                     if self.items[self.itempos].can_be_toggled:
                         if self.entersound != "":
                             entersound = self.pool.play_stationary(
                                 self.entersound)
                         if self.items[self.itempos].toggle_value == True:
                             lucia.output.speak(
                                 self.items[self.itempos].off_value)
                             self.items[self.itempos].toggle_value = False
                         else:
                             lucia.output.speak(
                                 self.items[self.itempos].on_value)
                             self.items[self.itempos].toggle_value = True
             elif lucia.key_down(lucia.K_LSHIFT) or lucia.key_down(
                     lucia.K_RSHIFT):
                 if self.items[self.itempos].has_value == True:
                     self.items[self.itempos].value = getinput(
                         "change value",
                         self.items[self.itempos].name + ". ",
                         value=self.items[self.itempos].value,
                         mode=self.items[self.itempos].value_mode,
                     )
                     lucia.output.speak("value set to " +
                                        str(self.items[self.itempos].value))
                     if self.entersound != "":
                         entersound = self.pool.play_stationary(
                             self.entersound)
         except Exception as e:
             lucia.output.speak(str(e))
Пример #15
0
# You should have received a copy of the GNU Lesser General Public License
# along with this program.  If not, see https://github.com/LuciaSoftware/lucia/blob/master/LICENSE.

# this is a simple testing game, used to show the features of lucia.
# Add this repository's lucia package to the PYTHON PATH, so this example can find the lucia module.
import sys

sys.path.append("../..")
import time

print("Importing lucia")
import lucia
import pygame

print("Initializing lucia")
lucia.initialize(audiobackend=lucia.AudioBackend.BASS)

print("Showing the window")
test = lucia.show_window()

while 1:
    time.sleep(0.005)
    lucia.process_events()
    if lucia.key_pressed(pygame.K_a):
        lucia.output.speak("a is pressed")
    if lucia.key_down(pygame.K_s):
        lucia.output.speak("s held down")
    if lucia.key_pressed(pygame.K_ESCAPE):
        lucia.quit()
        sys.exit()