def getWave(arr): sample = Sound( arr[0] * featureCoefs['Amplitude'], arr[1] * featureCoefs['Pitch'], arr[2] * featureCoefs['Decay'], arr[3] * featureCoefs['Type'], arr[4] * featureCoefs['Shift'], arr[5] * featureCoefs['Height'], arr[6] * featureCoefs['Slope']).getWave() for i in range(numFeatures, len(arr), numFeatures): sample += Sound(arr[i] * featureCoefs['Amplitude'], arr[i + 1] * featureCoefs['Pitch'], arr[i + 2] * featureCoefs['Decay'], arr[i + 3] * featureCoefs['Type'], arr[i + 4] * featureCoefs['Shift'], arr[i + 5] * featureCoefs['Height'], arr[i + 6] * featureCoefs['Slope']).getWave() return sample
def __init__(self, width, height): # We create the window self.width = width self.height = height FULLSCREEN = 0 self.dimension = (self.width, self.height) self.screen = pygame.display.set_mode(self.dimension, FULLSCREEN, 32) pygame.display.set_caption("TuxleTriad") elemText = ["Play", "Options", "Rules", "About", "Quit Game"] self.menu = [] for elem in elemText: self.menu.append(Button(elem, "Dearest.ttf", white)) posx = 400 posy = 400 - (60 * len(elemText)) for elem in self.menu: elem.rect.center = ((posx, posy)) posy += 100 self.bkgrnd, self.bkgrndRect = loadImage("background.jpg") self.bkgrndRect = self.bkgrnd.get_rect() # The Clock of the game, to manage the frame-rate self.clock = pygame.time.Clock() self.fps = 60 # We start the Sound object, playing music and sounds. self.sound = Sound() # Needed to keep track of the game if we do a pause during the game. self.app = None self.main()
def __init__(self, fileName, keys, stick, stones, helps, ball, bar, rightBall, level, game): """ Initialize a challenge @param self -- the challenge @param fileName -- a string that contains the sound name @param keys -- the key vector @param stick -- the stick @param stones -- the stones @param helps -- the helps @param ball -- the left ball that it is used in the animation @param bar -- the grey bar that it is used in the animation @param rightBall -- the right ball that it is used in the animation @param level -- the challenge level @param game -- the game """ self.fileName = fileName self.music = Sound() self.music.setFileName("sound/music/" + fileName) self.section = Section() self.section.setFileName("sound/section/" + fileName) self.section.setKeys(keys) self.stick = stick self.animation = Animation(stones, keys, helps, ball, rightBall, bar, game) self.ball = ball self.level = level self.attempts = 0 self.game = game
def __init__(self): self.vec_active = (0.3, -0.5) self.vec_passive = (0.4, -0.6) super().__init__(parent=camera.ui, model='assets/arm', texture=Textures.creat_texture('arm'), scale=0.2, rotation=Vec3(150, -10, 0), position=Vec2(self.vec_active)) self.sound = Sound()
def readMusic(f): F = open(f, 'r') sounds = [] for line in F: if (line[0] == "#"): continue l = line.split() for i in drange(0, len(l), 3): s = Sound(getNote(l[i]), float(l[i + 1]), float(l[i + 2])) sounds.append(s) return sounds
def __init__(self, parent=None): super(MainWindow, self).__init__() self.parent = parent self.tcp = parent.tcp self.tcp.recvAns.connect(self.parseAns) self.tcp.ConError.connect(self.tcpError) self.UID = parent.UID self.sound = Sound() self.initUI()
def setSound(self, id): """ Set a stone sound @param self -- the stone @param id -- a number that represents the ball note """ self.id = id self.sound = Sound() self.sound.setFileName("sound/notes/T" + str(self.id + 3))
def __init__(self, frame, size): self.size = size # make a new camera based on the size of the frame, then create the frame and add a start button. self.camera = Camera((0, 0), self.size[0] // Unit.UNIT, self.size[1] // Unit.UNIT, Unit.UNIT) self.player = Player(100, 100, Unit.UNIT, Unit.UNIT) self.keyboard = Keyboard() self.result = States.STATES[1] frame.set_keydown_handler(self.keyboard.key_down) frame.set_keyup_handler(self.keyboard.key_up) sound = Sound() self.tiles = Mapper.get_start_tiles(self.camera) sound.play_death()
def makeJob(self, msg, start, volume=None): """ Builds a scheduler Job object to annouce an mp3 at a certain time. """ announce = Sound(msg) announce.buildMp3() if volume: announce.setVolume(volume) Job = schedule.Job(interval=1, scheduler=self._scheduler) Job.unit = 'days' str_time = "{}:{}".format(start.hour, start.minute) print "Starting warning at: ", str_time Job.at(str_time).do(announce)
def main(): try: logger = Logger() sound = Sound(logger) #start the game aleph = Aleph(logger, sound, letters_gpios_pins_dict, start_button_gpio_pin, blink_record_gpio_pin, Config.lives).run_game() except (EnvironmentError, IOError) as err: sound.play_audio_file(Config.audio_fatal_error).play() logger.log_exception(err, locals()) for key in letters_gpios_pins_dict.keys(): GPIO.setup(key, GPIO.LOW) finally: GPIO.cleanup()
def __init__(self, argv, client, debugging_mqtt=False): super().__init__(argv, client, debugging_mqtt) self.logger.info(_("Props started")) if platform.system() != 'Windows': if self.logger.level != logging.DEBUG: self._gui.full_screen = True # exit fullscreen with Esc (so for props without a keyboard) else: self._gui.width = 592 self._gui.height = 333 self._gui.bg = 'black' self._gui.tk.config(cursor="none") self._texte = Text( self._gui, "") # "" value is translated to "-" for MQTT_DISPLAY_TOPIC self._texte.height = 1080 self._texte.text_color = 'green' self._texte.font = "Helvetica" if platform.system() != 'Windows': self._texte.size = "90" else: self._texte.size = "28" self._sound = Sound(self._logger) if platform.system() != 'Windows': os.system("amixer cset numid=3 1") # audio jack os.system("amixer set 'PCM' -- -1000") if self._mqttConnected: try: (result, mid) = self._mqttClient.publish(MQTT_DISPLAY_TOPIC, "-", qos=MQTT_DEFAULT_QoS, retain=True) except Exception as e: self._logger.error("{0} '{1}' on {2}".format( _("MQTT API : failed to call publish() for"), "-", MQTT_DISPLAY_TOPIC)) self._logger.debug(e)
def __init__(self, x, y, w, h, image=ResourcePaths.character_sprite_sheet): self.pos = Vector(x, y) self.dv = Vector(0, 0) self.direction = self.LEFT self.grounded = False self.w = w self.h = h self.tick_count = 0 self.state = self.IDLE self.live_image = simplegui.load_image(ResourcePaths.heart) self.image = simplegui.load_image(image) self.cols = self.image.get_width() // self.w self.rows = self.image.get_height() // self.h self.sprite_index = 22 self.last_point_standing = self.pos self.lives = 2#50 self.player_sound = Sound() self.ui = UI()
def __init__(self): self.config = Config() pygame.init() pygame.display.set_caption("ISN ILIES") self.fond = self.config.getBlue() self.fenetre = pygame.display.set_mode( (self.config.getSurfaceW(), self.config.getSurfaceH()), pygame.FULLSCREEN) #pygame.display.set_mode((surfaceW,surfaceH)) self.sound = Sound() self.sound.inAcceuil() # Groupe de sprites utilisé pour l'affichage self.groupeGlobal = pygame.sprite.Group() self.statut = True self.listBullet = ListBullet(self.config) self.vaisseau = Vaisseau(self.config, self.listBullet)
def __init__(self): self.connected = False self.gui_init = False self.msg_send = False self.run = True self.parent = None self.total_msg = 0 self.messages = [] self.hashlist = [] self.colors = [] self.total_msg_display = 6 self.mw_status = [None] * self.total_msg_display self.status = [None] * self.total_msg_display self.buffer = 1024 self.ore = 0 self.qty_cargo = 0 self.sound = Sound() self.load_config()
def __init__(self): pygame.init() pygame.mixer.init() pygame.display.set_caption("Sokoben") self.asset = Asset() self.background = self.asset.createBackground() self.sound = Sound(self.asset) self.asset.loadImages() self.asset.loadLevels() self.asset.loadSounds() self.asset.loadFonts() self.asset.loadControls() self.levelIndex = 0 self.level = None Controls.add('sound_enabled', self.asset.controls['sound_enabled'], (const.MAPWIDTH * const.TILEWIDTH) - ((1 * 64) + 64), 10, self.sound.enabled) Controls.add('sound_disabled', self.asset.controls['sound_disabled'], (const.MAPWIDTH * const.TILEWIDTH) - ((1 * 64) + 64), 10, not self.sound.enabled) Controls.add('reset', self.asset.controls['reset'], (const.MAPWIDTH * const.TILEWIDTH) - ((2 * 64) + 64), 10, True) Controls.add('undo', self.asset.controls['undo'], (const.MAPWIDTH * const.TILEWIDTH) - ((3 * 64) + 64), 10, True) Controls.add('next', self.asset.controls['next'], (const.MAPWIDTH * const.TILEWIDTH) - ((4 * 64) + 64), 10, True) Controls.add('back', self.asset.controls['back'], (const.MAPWIDTH * const.TILEWIDTH) - ((5 * 64) + 64), 10, True) Controls.add('solution', self.asset.controls['solution'], (const.MAPWIDTH * const.TILEWIDTH) - ((6 * 64) + 64), 10, False) self.clock = pygame.time.Clock() self.screen = pygame.display.set_mode( (const.MAPWIDTH * const.TILEWIDTH, (const.MAPHEIGHT - 1) * const.TILEANGLEHEIGHT + const.TILEHEIGHT))
def __init__(self): environ['SDL_VIDEO_CENTERED'] = '1' pg.mixer.pre_init(44100, -16, 2, 1024) pg.init() pg.display.set_caption('Fesitvus Frank') pg.display.set_mode((WINDOW_W, WINDOW_H)) self.screen = pg.display.set_mode((WINDOW_W, WINDOW_H)) self.clock = pg.time.Clock() self.oWorld = Map('1-1') self.oSound = Sound() self.oMM = MenuManager(self) self.run = True self.keyR = False self.keyL = False self.keyU = False self.keyD = False self.keyShift = False
def __init__ (self): environ['SDL_VIDEO_CENTERED'] = '1' pygame.mixer.pre_init(44100, -16, 2, 1024) pygame.init() pygame.display.set_caption('Team Bea Mario') pygame.display.set_mode((screen_width, screen_height)) self.screen = pygame.display.set_mode((screen_width, screen_height)) self.clock = pygame.time.Clock() self.object_world = Map('1-1') self.object_sound = Sound() self.object_menu_manager = menu_manager(self) # initial flags self.run = True self.moveRight = False self.moveLeft = False self.jump_up = False self.crouch = False self.shift = False # Runs when shift is held down
def __init__(self): environ['#'] = '1' pg.mixer.pre_init(44100, -16, 2, 1024) pg.init() pg.display.set_caption('Mario by techprogrammer007') pg.display.set_caption('@code_with_python_') pg.display.set_mode((WINDOW_W, WINDOW_H)) self.screen = pg.display.set_mode((WINDOW_W, WINDOW_H)) self.clock = pg.time.Clock() self.oWorld = Map('1-1') self.oSound = Sound() self.oMM = MenuManager(self) self.run = True self.keyR = False self.keyL = False self.keyU = False self.keyD = False self.keyShift = False
def main(): LoadImage() Text() Sound() while 1: # タイトル画面 if GAME_STATE == 0: Title() # ステージ 1-1 elif GAME_STATE == 1: Stage_1() # ステージ 1-2 elif GAME_STATE == 2: Stage_2() # ステージ 1-4 elif GAME_STATE == 3: Stage_3() # ステージ 1-4 elif GAME_STATE == 4: Stage_4()
def __init__(self, jeu, config, vaisseau, listBullet, app, *groupes): self.app = app self._fenetre = jeu.fenetre #jeu.fond = (0, 0, 0) self.config = config self.jeu = jeu self.sound = Sound() #jeu) self.listBullet = listBullet self.Vaisseau = vaisseau self.hud = Hud(jeu, self.Vaisseau) self.gameover = GameOver(self.jeu) self.listEnnemi = ListEnnemi(self.config, self.listBullet, self.Vaisseau, self.listBullet, jeu, self.sound) self.listMeteorite = ListMeteorite(self.config, self.listBullet, self.listEnnemi, self.sound, jeu, self.Vaisseau) self.vaisseauInit = Vaisseau(self.config, []) self.BulletInit = Bullet(self.config) self.EnnemiInit = Ennemi(self.config, []) self.MeteoriteInit = Meteorite(self.config) self.imgMeteorite = self.loadImg(self.MeteoriteInit.getImg()) self.imgBullet = [ self.loadImg(self.BulletInit.getImgType(0)), self.loadImg(self.BulletInit.getImgType(1)) ] self.imgFond = self.loadImg("images/fond.png") self.imgVaisseau = [] self.imgEnnemi = [] for i in range(8): imgV = self.loadImg(self.vaisseauInit.getImgDirection(i)) imgE = self.loadImg(self.EnnemiInit.getImgDirection(i)) self.imgVaisseau.append(imgV) self.imgEnnemi.append(imgE)
def __init__(self, gid, senderID=None, msg=None, parent=None): super(QChatWindow, self).__init__() self.parent = parent self.tcp = parent.tcp self.tcp.recvAns.connect(self.parseAns) self.msgTimer = QTimer() self.GID = gid self.SID = parent.parent.SID self.UID = parent.UID self.members = [] self.sound = Sound() self.initUI() if senderID: if type(senderID) == type(['list']): i = 0 for UID in senderID: self.appendText(UID,msg[i]) i += 1 else: self.appendText(senderID,msg)
def __init__(self, loc:Tuple[int,int], N: int, value: int, color:int=None, size=1, name:str=None, life_time=100): # what properties to have here ? # store the sound self.sound = Sound() # some nice propeties to have --> a cell shouldn't be alive forever self._life_time = life_time self.alive = True # this is the size of the board self._loc = loc self.N = N # self.last_move_prob = np.array([1/3.0,1/3.0,1/3.0]) # should add some momentum to the game # need to store the history of encounter for this cell self._name = name self._value = value self.history_tracker = CellHistoryTracker() self._next_loc = None if not color: # random generate a color from [0..255] self.color = random.randint(125, 255) else: self.color = color
def __init__(self, fileName, x, y, polygon, game): """ Initialize a Key @param self -- the key @param fileName -- a string that contains the image name @param x -- a horizontal position of key @param y -- a vertical position of key @param polygon -- a list of (x,y) pairs @param game -- the game """ self.image = pygame.image.load("image/key/" + fileName + ".png") self.image.set_alpha(None) # disable alpha. self.image.convert() self.image.set_colorkey((255, 0, 255)) # magenta self.imageHover = pygame.image.load("image/keyHover/" + fileName + ".png") self.imageHover.set_alpha(None) # disable alpha. self.imageHover.convert() self.imageHover.set_colorkey((255, 0, 255)) # magenta self.imageDown = pygame.image.load("image/keyDown/" + fileName + ".png") self.imageDown.set_alpha(None) # disable alpha. self.imageDown.convert() self.imageDown.set_colorkey((255, 0, 255)) # magenta self.id = int(fileName) self.fileName = fileName self.sound = Sound() self.sound.setFileName("sound/notes/T" + str(int(fileName) + 3)) self.x = x self.y = y self.polygon = polygon self.isHover = False self.isDown = False self.isVisible = True self.mouseInside = False self.game = game
def config(self, res=(800, 600), client=False, xid=False): print "Configurando Juego:" print "\tres:", res print "\tclient", client print "\txid", xid self._res = res self._client = client if xid: os.putenv("SDL_WINDOWID", str(xid)) pygame.init() from pygame.locals import MOUSEMOTION from pygame.locals import MOUSEBUTTONUP from pygame.locals import MOUSEBUTTONDOWN from pygame.locals import JOYAXISMOTION from pygame.locals import JOYBALLMOTION from pygame.locals import JOYHATMOTION from pygame.locals import JOYBUTTONUP from pygame.locals import JOYBUTTONDOWN from pygame.locals import VIDEORESIZE from pygame.locals import VIDEOEXPOSE from pygame.locals import USEREVENT from pygame.locals import QUIT from pygame.locals import ACTIVEEVENT from pygame.locals import KEYDOWN from pygame.locals import KEYUP pygame.event.set_blocked([ MOUSEMOTION, MOUSEBUTTONUP, MOUSEBUTTONDOWN, JOYAXISMOTION, JOYBALLMOTION, JOYHATMOTION, JOYBUTTONUP, JOYBUTTONDOWN, ACTIVEEVENT, USEREVENT, KEYDOWN, KEYUP ]) pygame.event.set_allowed([QUIT, VIDEORESIZE, VIDEOEXPOSE]) pygame.mouse.set_visible(False) #pygame.display.set_mode((0, 0), pygame.DOUBLEBUF | pygame.FULLSCREEN, 0) pygame.display.set_mode(self._res, pygame.DOUBLEBUF, 0) pygame.display.set_caption("JAMtank") self._win = pygame.Surface(RES) self._real_win = pygame.display.get_surface() self._audio = Sound()
def __init__(self): pygame.init() self.SCREEN_WIDTH = 800 self.SCREEN_HEIGHT = 600 self.display = pygame.display.set_mode((self.SCREEN_WIDTH, self.SCREEN_HEIGHT)) pygame.display.set_caption("DoocHunt") pygame.mouse.set_visible(False) self.stoper = Stoper() self.sound = Sound() self.ui = UserInterface(self.display) self.run = True self.crosshair = Crosshair(self.display, self.SCREEN_WIDTH, self.SCREEN_HEIGHT) self.ducks = [] self.groundImage = pygame.image.load("images/ground.png") self.tree = pygame.image.load("images/tree.png") self.duckSpriteRepository = DuckSpriteSetRepository() self.dogSpriteSetRepository = DogSpriteSetRepository() self.gameState = GameState.GAME_STARTING self.dog = Dog(self.display, self.stoper, self.dogSpriteSetRepository.getCollection()) self.level = 0 self.ammoCount = self.level + 2 self.duckCount = self.level + 1
def __init__(self, config, logger): super(MainWidget, self).__init__() self.config = config self.logger = logger self.imageDir = self.config.get("display", "image_dir", fallback="images") self.alarm = None self.route = ([], None, None) self.seenPager = False self.seenXml = False self.seenJson = False self.reportDone = False self.alarmDateTime = None self.forwarder = Forwarder(config, logger) self.notifier = Notifier(config, logger) self.sound = Sound(config, logger) self.gpioControl = GpioControl(config, logger) self.tts = TextToSpeech(config, logger) self.reportTimer = QTimer(self) self.reportTimer.setInterval( \ self.config.getint("report", "timeout", fallback = 60) * 1000) self.reportTimer.setSingleShot(True) self.reportTimer.timeout.connect(self.generateReport) self.simTimer = QTimer(self) self.simTimer.setInterval(10000) self.simTimer.setSingleShot(True) self.simTimer.timeout.connect(self.simTimeout) #self.simTimer.start() self.idleTimer = QTimer(self) idleTimeout = self.config.getint("display", "idle_timeout", fallback=30) self.idleTimer.setInterval(idleTimeout * 60000) self.idleTimer.setSingleShot(True) self.idleTimer.timeout.connect(self.idleTimeout) self.screenTimer = QTimer(self) screenTimeout = self.config.getint("display", "screen_timeout", fallback=0) self.screenTimer.setInterval(screenTimeout * 60000) self.screenTimer.setSingleShot(True) self.screenTimer.timeout.connect(self.screenTimeout) if self.screenTimer.interval() > 0: self.screenTimer.start() # Presence ----------------------------------------------------------- self.presenceTimer = QTimer(self) self.presenceTimer.setInterval(1000) self.presenceTimer.setSingleShot(False) self.presenceTimer.timeout.connect(self.checkPresence) self.presenceTimer.start() self.switchOnTimes = [] self.switchOffTimes = [] if self.config.has_section('presence'): onRe = re.compile('on[0-9]+') offRe = re.compile('off[0-9]+') for key, value in self.config.items('presence'): ma = onRe.fullmatch(key) if ma: tup = self.parsePresence(key, value) if tup: self.switchOnTimes.append(tup) continue ma = offRe.fullmatch(key) if ma: tup = self.parsePresence(key, value) if tup: self.switchOffTimes.append(tup) continue self.updateNextSwitchTimes() # Appearance --------------------------------------------------------- self.logger.info('Setting up X server...') subprocess.call(['xset', 's', 'off']) subprocess.call(['xset', 's', 'noblank']) subprocess.call(['xset', 's', '0', '0']) subprocess.call(['xset', '-dpms']) self.move(0, 0) self.resize(1920, 1080) self.setWindowTitle('Alarmdisplay') self.setStyleSheet(""" font-size: 60px; background-color: rgb(0, 34, 44); color: rgb(2, 203, 255); font-family: "DejaVu Sans"; """) # Sub-widgets -------------------------------------------------------- layout = QVBoxLayout(self) layout.setSpacing(0) layout.setContentsMargins(0, 0, 0, 0) self.stackedWidget = QStackedWidget(self) layout.addWidget(self.stackedWidget) self.idleWidget = IdleWidget(self) self.idleWidget.start() self.stackedWidget.addWidget(self.idleWidget) self.alarmWidget = AlarmWidget(self) self.stackedWidget.addWidget(self.alarmWidget) self.errorWidget = QLabel(self) self.errorWidget.setGeometry(self.contentsRect()) self.errorWidget.setAlignment(Qt.AlignCenter | Qt.AlignVCenter) self.errorWidget.setStyleSheet(""" background-color: transparent; font-size: 20px; color: red; """) # Shortcuts ---------------------------------------------------------- action = QAction(self) action.setShortcut(QKeySequence("1")) action.setShortcutContext(Qt.ApplicationShortcut) action.triggered.connect(self.exampleJugend) self.addAction(action) action = QAction(self) action.setShortcut(QKeySequence("2")) action.setShortcutContext(Qt.ApplicationShortcut) action.triggered.connect(self.exampleEngels) self.addAction(action) action = QAction(self) action.setShortcut(QKeySequence("3")) action.setShortcutContext(Qt.ApplicationShortcut) action.triggered.connect(self.exampleSack) self.addAction(action) action = QAction(self) action.setShortcut(QKeySequence("4")) action.setShortcutContext(Qt.ApplicationShortcut) action.triggered.connect(self.exampleWolfsgrabenPager) self.addAction(action) action = QAction(self) action.setShortcut(QKeySequence("5")) action.setShortcutContext(Qt.ApplicationShortcut) action.triggered.connect(self.exampleWolfsgrabenMail) self.addAction(action) action = QAction(self) action.setShortcut(QKeySequence("6")) action.setShortcutContext(Qt.ApplicationShortcut) action.triggered.connect(self.exampleWald) self.addAction(action) action = QAction(self) action.setShortcut(QKeySequence("7")) action.setShortcutContext(Qt.ApplicationShortcut) action.triggered.connect(self.exampleStadtwerkePager) self.addAction(action) action = QAction(self) action.setShortcut(QKeySequence("8")) action.setShortcutContext(Qt.ApplicationShortcut) action.triggered.connect(self.exampleLebenshilfe) self.addAction(action) action = QAction(self) action.setShortcut(QKeySequence("9")) action.setShortcutContext(Qt.ApplicationShortcut) action.triggered.connect(self.exampleHuissen) self.addAction(action) # Threads ------------------------------------------------------------ self.receiverThread = QThread() self.alarmReceiver = AlarmReceiver(self.config, self.logger) self.alarmReceiver.receivedAlarm.connect(self.receivedPagerAlarm) self.alarmReceiver.finished.connect(self.receiverThread.quit) self.alarmReceiver.errorMessage.connect(self.receiverError) self.alarmReceiver.moveToThread(self.receiverThread) self.receiverThread.started.connect(self.alarmReceiver.receive) self.receiverThread.start() self.websocketReceiverThread = QThread() self.websocketReceiver = WebsocketReceiver(self.config, self.logger) self.websocketReceiver.receivedAlarm.connect( \ self.receivedWebsocketAlarm) self.websocketReceiver.finished.connect( \ self.websocketReceiverThread.quit) self.websocketReceiver.moveToThread(self.websocketReceiverThread) self.websocketReceiverThread.started.connect( \ self.websocketReceiver.receive) self.websocketReceiverThread.start() if self.websocketReceiver.status: self.statusWidget = StatusWidget(self) layout.addWidget(self.statusWidget) self.websocketReceiver.receivedStatus.connect( \ self.statusWidget.setStatus) if self.config.has_section('email') and \ self.config.get("email", "imap_host", fallback = ''): from ImapMonitor import ImapMonitor self.imapThread = QThread() self.imapMonitor = ImapMonitor(self.config, self.logger) self.imapMonitor.receivedAlarm.connect(self.receivedXmlAlarm) self.imapMonitor.moveToThread(self.imapThread) self.imapMonitor.finished.connect(self.imapThread.quit) self.imapThread.started.connect(self.imapMonitor.start) self.imapThread.start() self.socketListener = SocketListener(self.logger) self.socketListener.pagerAlarm.connect(self.receivedPagerAlarm) self.socketListener.xmlAlarm.connect(self.receivedXmlAlarm) self.cecThread = QThread() self.cecThread.start() self.cecCommand = CecCommand(self.logger) self.cecCommand.moveToThread(self.cecThread) self.report = AlarmReport(self.config, self.logger) try: self.notifier.startup() except: self.logger.error('Startup notification failed:', exc_info=True) self.logger.info('Setup finished.')
def main(): pygame.init() screen = pygame.display.set_mode(screen_size) screen_rect = screen.get_rect() clock = pygame.time.Clock() offset = repeat((0, 0)) sound = Sound() ''' Add whatever soundtrack files you want to the mp3 folder, and then add them to the soundtrack by calling sound.add_music('Ambient_Blues_Joe_ID_773.mp3') # replace with whatever the filename is Once you have added the tracks you want, just call sound.play_music() When the song finishes, the library will queue up and play the next one in the order you added them --------------------------------- You can add sounds to the sound library by calling sound.add_sound('footstep','footstep_sound.mp3') It assumes the sounds are in the mp3 folder To play sounds in the library, you can call sound.play_sound('footstep') ''' level = Level('level_1.game') #a game level definition players = pygame.sprite.Group() player = Player(level.get_player_starting_position(),lives,level.block_size,gravity,friction) players.add(player) enemies = pygame.sprite.Group() for e in level.get_enemies(): enemy = Enemy(gravity,e,level.block_size) enemies.add(enemy) floors = pygame.sprite.Group() for f in level.get_floor(): floor = Floor(gravity,f,level.block_size) floors.add(floor) while True: clock.tick(FPS) screen.fill(Color.black) for event in pygame.event.get(): if event.type == pygame.QUIT: pygame.quit() sys.exit(0) if event.type == sound.event(): song.play_music() keys = pygame.key.get_pressed() # a complete list of the pygame key constants can be found here: https://www.pygame.org/docs/ref/key.html if keys[pygame.K_RIGHT]: player.move(1) if keys[pygame.K_LEFT]: player.move(-1) if keys[pygame.K_UP]: player.jump() floors.update() enemies.update() players.update(level,enemies,floors) full_screen = level.get_full_screen() floors.draw(full_screen) enemies.draw(full_screen) players.draw(full_screen) if level.screen_shake: offset = level.shake() level.screen_shake = False screen.blit(level.get_screen(),next(offset),level.get_rect(screen_size,player)) pygame.display.flip()
def initializeSoundMap(): i = 0 for key, value in Config.BANK_AND_BUTTON_SOUND_MAP.items(): bankAndButtonToSoundDict[key] = Sound(value, i) i += 1
# -*- coding: utf-8 -*- import RPi.GPIO as GPIO ## from Sound import Sound from Bouncer import Bouncer from GpioClassLibrary import * import time import datetime from Lullaby import * import subprocess bouncer = Bouncer() lullaby = Lullaby() sound = Sound() warningStack = 0 noSleepCheckStack = 0 babyCryStack = 0 jog = Jog() GPIO.add_event_detect(jog.jogDown, GPIO.RISING, callback=jog.jogEvent) ### 1) 수면 시작 및 종료시 DB로 데이터 전송 ### ### 2) 자동 수면 유도 기능에 따라 바운서 작동 ### class Sleep(): ### 초기화 하는 메소드 ### def __init__(self): self.sleepCheckFlag = 1 lullaby.isPlaying = 0
def __init__(self, ip=None, port=None, parent=None): super(LoginWindow, self).__init__() # Perform Tcp Connection self.tcp = TcpClient(ip, port) self.tcp.recvAns.connect(self.parseAns) # Connect errorhandling self.tcp.ConError.connect(self.tcpError) self.tcp.connected.connect(self.tcpConnected) # Setup reconnect Timer self.rconTimer = QTimer(self) self.rconTimer.timeout.connect(self.tryReconnect) # Create Sound Object self.sound = Sound() # init userData self.userName = None self.passwd = None self.StatusUSER = False self.StatusPASS = False self.conStat = False self.SID = None self.UID = None # Adjust Window ---------------------------------------------- # Set Title self.setWindowTitle('PySIMS') # Set Windwo Icon self.setWindowIcon(QIcon('img/pysims_icon_16.png')) self.setFixedSize(200, 350) # Create widgets --------------------------------------------- # Create Logo self.logo = QPixmap('img/pysims_logo.png') self.logoLabel = ClickableLabel(self) self.logoLabel.setPixmap(self.logo) # Create Forgot Password self.forgotPassLabel = ClickableLabel( "<font size=10px>Passwort vergessen?</font>") #self.forgotPassLabel.set # Create Sign Up self.SignUpLabel = ClickableLabel( "<font size=10px>Registrieren</font>") # Create Message Label self.messageLabel = QLabel() # Create Username Input self.usernameEdit = QLineEdit("") self.usernameLabel = QLabel("Benutzername:") # Create Password Input self.passwordEdit = QLineEdit("") self.passwordLabel = QLabel("Passwort:") # Set Password Input to not readable self.passwordEdit.setEchoMode(QLineEdit.Password) # Create Login Button self.loginBtn = QPushButton("Login") # Create layout and add widgets ------------------------------ # Build Logo Layout hboxLogo = QHBoxLayout() hboxLogo.addStretch(1) hboxLogo.addWidget(self.logoLabel) hboxLogo.addStretch(1) # Build Lower Layout hboxReg = QHBoxLayout() hboxReg.addWidget(self.forgotPassLabel) hboxReg.addStretch(1) hboxReg.addWidget(self.SignUpLabel) # Build Main Layout layout = QVBoxLayout() layout.addLayout(hboxLogo) layout.addWidget(self.messageLabel) layout.addWidget(self.usernameLabel) layout.addWidget(self.usernameEdit) layout.addWidget(self.passwordLabel) layout.addWidget(self.passwordEdit) layout.addWidget(self.loginBtn) layout.addLayout(hboxReg) # Set dialog layout self.setLayout(layout) # Signals and Slots ------------------------------------------ # Add button signal to sendLogin slot self.loginBtn.clicked.connect(self.sendUser) self.usernameEdit.returnPressed.connect(self.jumpFunction1) self.passwordEdit.returnPressed.connect(self.jumpFunction2) # Add mouseReleaseEvent to forgotPass Slot self.connect(self.forgotPassLabel, SIGNAL('clicked()'), self.forgotPass) # Add mouseReleaseEvent to register Slot self.connect(self.SignUpLabel, SIGNAL('clicked()'), self.register) self.connect(self.logoLabel, SIGNAL('clicked()'), self.logoClick)