def perform_action(what): global c, menu, menumusic, menulist, menupos, can_press_escape try: if what == 'play': map.parsedata("inderion station") menumusic.stop() menu=False menulist=list() elif what == 'change language': langlist=[] for x in find_dirs("locale"): langlist.append("language: "+x) langlist.append("exit to main menu") menulist=langlist menupos=-1 speak(_("select a language")) menu=True can_press_escape=False elif what[0:10] == "language: ": language = what.replace("language: ", "") global lang lang=gettext.translation(language, localedir='locale', languages=[language]) lang.install() auto.speak(_("language set to ")+_(language)) with open("locale/savedlng", "w") as f: f.write(language) main_menu() elif what == "exit to main menu": main_menu() elif what == "exit": exit() except Exception as e: log_add_entry("\r\n"+str(e), True)
def checkplatform(): try: global jumping, WalkTime if map.tile(me.x, me.y, me.z) != "" and jumping == 1: if "wall" not in map.tile(me.x, me.y, me.z): tempsplit=map.mytile().split("|") landingsounds=list() for x in tempsplit: landingsounds.append("sounds/footsteps/"+x+"/landing/"+str(random.randint(1, len(find_files("sounds/footsteps/"+x+"/landing"))))+".wav") for x in landingsounds: landsound=oalOpen(x, ".wav") landsound.set_source_relative(True) sourcelist.append(landsound) landsound.play() jumping=0 WalkTime=MainWalkTime global step step=0 walktimer.restart() global ascenddistance, descenddistance ascenddistance=0 descenddistance=0 except Exception as e: auto.speak("\r\nError acurd on landing: {0}".format(str(e)))
def cleanup(): try: for a in sourcelist: if a == None or a.get_state()==AL_STOPPED: a.destroy() sourcelist.remove(a) except Exception as e: auto.speak("\r\nError acurd on cleaning up sound sources: {0}".format(str(e)))
def mainmenu(): m=menu.menu() m.add_item_tts("Start game","start") m.add_item_tts("Exit game","exit") obj=m.run("Main menu") if obj.name=="start": auto.speak("You selected start.") time.sleep(2) mainmenu()
def main_menu(): global menu, menulist, menupos, can_press_escape reset() menulist=['play', 'change language', 'exit'] menupos=-1 menu=True can_press_escape=False if menumusic.get_state() != AL_PLAYING: menumusic.play() auto.speak(_("Main menu. Select an item with up and down. Press enter to activate the item"))
def __init__(self, clicksound, edgesound, wrapsound, entersound, opensound, items, itempos=0, title="menu", fpscap=120): self.clicksound=clicksound self.edgesound=edgesound self.wrapsound=wrapsound self.entersound=entersound self.opensound=opensound self.itempos=itempos self.items=items auto.speak(title+". "+items[itempos]) # self.clock=pygame.time.Clock() self.fpscap=fpscap
def mainmenu(): m = menu.menu(select_sound="snd/Menu_Select.ogg", move_sound="snd/Menu_Click.ogg", disabled_text="This option is disabled.") m.add_item_tts("Start game", "start") m.add_item_tts("Exit game", "exit", enabled=False) obj = m.run("Main menu") if obj.name == "start": auto.speak("You selected start.") time.sleep(2) mainmenu()
def falldown(): try: if falltime.elapsed()>=60 and falling==1: falltime.restart() me.z-=1 global falldistance falldistance+=1 if fallingwind.get_state() != AL_PLAYING: fallingwind.play() if fallingwind.gain<2.0: fallingwind.set_gain(fallingwind.gain+0.01) except Exception as e: auto.speak("\r\nError acurd while falling down: {0}".format(str(e)))
def run(self): try: return self.loop() except Exception as e: auto.speak(str(e))
def log_add_entry(entry, should_speak=False, add_to_logger=False): if add_to_logger==True: log.add_entry(entry) logging.exception(entry) if should_speak: auto.speak(entry)
def speak(text): try: auto.speak(text) except Exception as e: auto.speak("Error on speaking a text: "+str(e))
#This example will show you how to speak a simple string through your currently selected screen reader #import time, in order to delay the code while the screen reader speaks. import time #import the auto speaker from the speech module from AGK.speech import auto #speak the text. auto.speak("This is a test.") #Sleep so the speech has time to finish. time.sleep(1)
def parsedata(mapname): config = None try: config = configobj.ConfigObj("maps/" + mapname + ".map") for m in config: if m[0:7] == "console": x = int(config[m]["x"]) y = int(config[m]["y"]) z = int(config[m]["z"]) name = config[m]["name"] stations = config[m]["stations"].split(",") consoles.append(console.console(x, y, z, name, stations)) if m[0:4] == "door": x = int(config[m]["x"]) y = int(config[m]["y"]) z = int(config[m]["z"]) opensound = config[m]["opensound"] closesound = config[m]["closesound"] door.append(doors.door(x, y, z, opensound, closesound)) if m[0:4] == "wall": x = int(config[m]["x"]) y = int(config[m]["y"]) z = int(config[m]["z"]) length = int(config[m]["length"]) side = int(config[m]["side"]) depth = int(config[m]["depth"]) spawn_tile(x, (x + side - 1), y, (y + -(length) + 1), z, (z + depth), "wall") if m[0:9] == "randomamb": x = int(config[m]["x"]) y = int(config[m]["y"]) z = int(config[m]["z"]) sp = config[m]["sounds"].split(",") time = int(config[m]["time"]) reference_distance = 1.0 rolloff_factor = 1.0 if "reference_distance" in config[m]: reference_distance = float(config[m]["reference_distance"]) if "rolloff_factor" in config[m]: rolloff_factor = float(config[m]["rolloff_factor"]) randomambs.append( randomambience.RandomAmbience(x, y, z, sp, time, reference_distance, rolloff_factor)) if m[0:4] == "room": roomx = int(config[m]["x"]) roomy = int(config[m]["y"]) roomz = int(config[m]["z"]) roomsound = config[m]["sound"] roomtype = config[m]["type"] roomlengthx = int(config[m]["lengthx"]) roomlengthy = int(config[m]["lengthy"]) roomdepth = int(config[m]["depth"]) if "description" in config[m]: roomdesc = config[m]["description"] spawn_room(roomx, (roomx + roomlengthx - 1), roomy, (roomy + -(roomlengthy) + 1), roomz, (roomz + roomdepth), roomsound) spawn_tile(roomx, (roomx + roomlengthx - 1), roomy, (roomy + -(roomlengthy) + 1), roomz, (roomz + roomdepth), roomtype) g.mapname = mapname g.loaded = True except Exception as e: auto.speak("Error on parsing data: " + str(e))
#import import pygame from AGK.speech import auto from AGK.mainframe import window, keyboard #create a window. w = window.window("test window") w.show() while 1: #a test of key holder if keyboard.down(pygame.K_a): auto.speak("a") if keyboard.pressed() == pygame.K_ESCAPE: break