Exemplo n.º 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)
Exemplo n.º 2
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)
Exemplo n.º 3
0
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():
    #Show window
    lucia.show_window("Simple Sound Example.")
    #Play a stationary sound
    #Stationary means that the sound cannot move, regardless of what the player does
    #The first parameter is the filename, while the second one dictates whether the sound can loop or not
    sound_pool.play_stationary("ding.ogg", True)
    while 1:
        #Allow lucia to update it's internal queues and events
        lucia.process_events()
        #No extra code is needed to handle when the user presses alt f4, Lucia does this on it's own.
        #Sleep for 2 milliseconds
        lucia.pygame.time.wait(2)
Exemplo n.º 6
0
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():
	#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()
Exemplo n.º 8
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)
Exemplo n.º 9
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)
Exemplo n.º 10
0
import logging, lucia, time
from lucia import utils

# Un comment this for debugging messages
#handler = logging.StreamHandler() # Logs to terminal
#formatter = logging.Formatter('%(asctime)s: %(levelname)s from %(name)s - %(message)s') # Sets the format in which the messages are displayed
#handler.setFormatter(formatter)
#lucia.logger.addHandler(handler)

lucia.initialize(audiobackend=lucia.AudioBackend.OPENAL)
window = lucia.show_window("shapes demo")

# Listener coordinates
x = 0
y = 0
width = 30
height = 30

# Set up the game field
field = list(range(width))
for ix in range(0, width):
    field[ix] = list(range(height))
    for iy in range(0, height):
        field[ix][iy] = 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
Exemplo n.º 11
0
import lucia

lucia.initialize()
lucia.show_window()
result = lucia.ui.VirtualInput()
result.run()
lucia.quit()
Exemplo n.º 12
0
import logging, lucia, time
from lucia import utils

handler = logging.StreamHandler()  # Logs to terminal
formatter = logging.Formatter(
    '%(asctime)s: %(levelname)s from %(name)s - %(message)s'
)  # Sets the format in which the messages are displayed
handler.setFormatter(formatter)
lucia.logger.addHandler(handler)

lucia.initialize(audiobackend=lucia.AudioBackend.OPENAL)
window = lucia.show_window()

textDirections = {
    90: "north",
    45: "northeast",
    0: "east",
    315: "southeast",
    270: "south",
    225: "southwest",
    180: "west",
    135: "northwest"
}

# Listener coordinates
x = 0
y = 0
oldX = x
oldY = y
direction = 90
oldDirection = direction
Exemplo n.º 13
0
# 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("../..")

print("Importing lucia")
import lucia

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

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

print("Making menu")


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")
Exemplo n.º 14
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.

# Importing lucia
import lucia, logging

# Uncomment this if you want to see debug messages
handler = logging.StreamHandler() # Logs to terminal
#handler = logging.FileHandler("debug.log") # Logs to a specified file
formatter = logging.Formatter('%(asctime)s: %(levelname)s from %(name)s - %(message)s') # Sets the format in which the messages are displayed
handler.setFormatter(formatter)
lucia.logger.addHandler(handler)
# For mor information on logging: https://docs.python.org/3/howto/logging.html

# Initializing lucia
lucia.initialize(audiobackend=lucia.AudioBackend.BASS)

# Showing the window
demo = lucia.show_window("demo of the pop dialog")

SOUNDS = {
	"enter": "sounds\\mSelect.wav",
}

message = lucia.ui.PopDialog(volume=25, enter_sound=SOUNDS["enter"])
#result = message.run("If we desire to know what ideas men held in heathen times about the life beyond the grave, it is natural to turn first to the evidence of archaeology.")
result = message.run("sounds\\intro.wav", True)

lucia.quit()
Exemplo n.º 15
0
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# 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)
Exemplo n.º 16
0
def test_show_window():
    if lucia.running == False:
        lucia.initialize()
    lucia.show_window()
    assert lucia.window is not None
Exemplo n.º 17
0
handler.setFormatter(formatter)
lucia.logger.addHandler(handler)
# For mor information on logging: https://docs.python.org/3/howto/logging.html

# Initializing lucia
lucia.initialize(audiobackend=lucia.AudioBackend.BASS)


def change_value(menu, direction):
    if 0 < menu.volume + direction < 100:
        menu.volume += direction * 5
        lucia.output.speak(f"volume now set to: {menu.volume}")


# Showing the window
demo = lucia.show_window("Simple Menu Demo")

# Making menu
menu = lucia.ui.MenuExtended(title="demo menu",
                             volume=80,
                             scroll_sound=SOUNDS["scroll"],
                             open_sound=SOUNDS["open"])
menu.add_item("enter some text", enter_value=True)
menu.add_item("sliding value", slider_function=change_value)
menu.add_item("toggleable item",
              can_be_toggled=True,
              toggle_labels=["activate", "deactivate"],
              toggle_hint="press space to change to")
menu.add_item("quit", can_return=True)

print(menu.run("Select an item"))