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)
def main(): #Window tytle test = lucia.show_window("Menu") #Now we insert the menu elements MenuItems= [ menu2.MenuItem("start", can_return=True), menu2.MenuItem("options", can_return=True), menu2.MenuItem("information", can_return=True), menu2.MenuItem("exit", can_return=True), ] #Now let's list the sounds of the menu #No sounds will play do to them not being provided with the example. #You can place items named scroll1.wav, enter1.wav, and border1.wav in the same directory as the script and the menu will react accordingly. menu1=menu2.Menu(items=MenuItems, clicksound="scroll1.wav", entersound="enter1.wav", edgesound="border1.wav", itempos=0, on_index_change=None) #We make the menu come out only when the user presses exit. while 1: result = menu1.run() if result[0]["name"] == "start": lucia.output.speak("Starting the game...") if result[0]["name"] == "information": lucia.output.speak("This is a test!") if result[0]["name"] == "options": lucia.output.speak("Here are the options!") if result[0]["name"] == "exit": lucia.output.speak("Thanks for playing!") lucia.quit() sys.exit()
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)
def main(): #Create a game window lucia.show_window("Timer Example.") #Create a timer countdown_timer = lucia.utils.timer.Timer() #Loop for 2 seconds while countdown_timer.elapsed <= 2000: #Allow lucia to update it's internal queues and events lucia.process_events() #Sleep for 2 milliseconds lucia.pygame.time.wait(2) #Output a message lucia.output.output("Now you see me...") #Restart the timer before continuing to loop countdown_timer.restart() #Loop for another 2 seconds while countdown_timer.elapsed <= 2000: #Allow lucia to update it's internal queues and events lucia.process_events() #Sleep for 2 milliseconds lucia.pygame.time.wait(2) #Output another message lucia.output.output("Now you don't!") lucia.quit() sys.exit()
def main(): #Create a game window lucia.show_window("Input Example.") #Create the virtualInput object. See the module itself for further details input_handler = lucia.ui.virtualinput.virtualInput() #Gather our user input. user_response = input_handler.run("Please enter something!") #Output our response print(user_response) #Properly quit lucia.quit() sys.exit()
def main(): #Create a game window lucia.show_window("Basic Menu Example.") #Create a menu. This will not contain any sounds and will not be explain in great detail here, the module is commented extremely well for a change. menu_handler = lucia.ui.menu.Menu() #Add items menu_handler.add_item_tts("Start game") menu_handler.add_item_tts("Options") menu_handler.add_item_tts("Exit.") #Run the menu choice = menu_handler.run("Please select an item with your up and down arrow keys") #Output the user's choice print(choice) #Properly exit lucia.quit() sys.exit()
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)
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)
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Lesser General Public License for more details. # # 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. # Importing lucia import lucia # Initializing lucia lucia.initialize(audiobackend=lucia.AudioBackend.BASS) # Showing the window demo = lucia.show_window("A yes or no question") SOUNDS = { "open": "sounds\\mPop.wav", "scroll": "sounds\\mChange.wav", "border": "sounds\\mRoll.wav", "enter": "sounds\\mSelect.wav", } question = lucia.ui.SimpleQuestion("agree", "disagree", scroll_sound=SOUNDS["scroll"]) question.align_selection_vertical() result = question.run("Select yes or no.") print(result) lucia.quit()