Пример #1
0
 def at_beeper(self, x, y):
     '''Notifies interested parties about robot
     being at a beeper.
     '''
     onbeepersound = os.path.join(conf.getSettings().SOUNDS_DIR, 'beep.wav')
     if os.path.isfile(onbeepersound):
         play(onbeepersound)
Пример #2
0
 def sound_change(self, value):
     changed = self.game.save.get_setting("sound_volume") != value
     self.game.save.set_setting("sound_volume", value)
     self.game.save.save()
     sound.update_volume()
     if changed:
         sound.play("laser1")
Пример #3
0
    def update(self, dt, player):
        if player.grounded:
            if globals.keys[key.RIGHT] or globals.keys[key.LEFT]:
                player.dy = self.JUMP_DY
                sound.play('clunk.wav')

        super(SpringPlayerMovement, self).update(dt, player)
Пример #4
0
    def update(self, dt, player):
        if player.grounded:
            if globals.keys[key.UP]:
                player.dy = self.JUMP_DY
                sound.play('clunk.wav')

        super(JumpPlayerMovement, self).update(dt, player)
Пример #5
0
 def toggle_paused(self):
     self.paused = not self.paused
     if self.paused:
         sound.pause_music()
     else:
         sound.resume_music()
     sound.play("pause")
Пример #6
0
    def fire(self, scene):
        scene.sm.transition(levelstates.TankFireState(scene, self))
        dx,dy = OFFSETS_FROM_DIRS[self.last_move_direction]
        self.fire_obj = framesprite.FrameSprite("assets/tankfire.png", 12)
        self.fire_obj.set_frame(self.last_move_direction)
        scene.ui_group.add(self.fire_obj)
        off = (0,0)
        if self.last_move_direction == 0: off = (-2, -9)
        elif self.last_move_direction == 1: off = (0, -8)
        elif self.last_move_direction == 2: off = (2, -9)
        elif self.last_move_direction == 3: off = (0, -4)
        self.fire_obj.move((self.gx + dx) * game.TILESIZE + off[0], (self.gy + dy) * game.TILESIZE + off[1])
        self.step_animation = self.post_fire_step_animation
        self.set_frame(self._frame // 2 + 8)

        self.bullet_obj = framesprite.FrameSprite("assets/tankshell.png", 8)
        self.bullet_obj.set_frame(self.last_move_direction)
        scene.ui_group.add(self.bullet_obj)
        off = (0,0)
        if self.last_move_direction == 0: off = (-2, -6)
        elif self.last_move_direction == 1: off = (2, -8)
        elif self.last_move_direction == 2: off = (2, -6)
        elif self.last_move_direction == 3: off = (2, 0)        
        self.bullet_obj.move((self.gx + dx) * game.TILESIZE + off[0], (self.gy + dy) * game.TILESIZE + off[1])
        sound.play("tankfire")
	def __init__(self, name, quantity, coords, destinationGroup='default', imageName=None):
		"""imageName need only be specified if it's not the same as the item name"""
		pygame.sprite.Sprite.__init__(self)
		self.add(my.allItems)
		self.add(my.itemsOnTheFloor)
		self.name, self.quantity, self.coords = name, quantity, coords
		self.rect = pygame.Rect(my.map.cellsToPixels(self.coords), (my.CELLSIZE, my.CELLSIZE))

		if not imageName:
			imageName = self.name
		self.image = Item.IMG[imageName]
		self.carryImage = pygame.transform.scale(self.image, (10, 10))

		if destinationGroup == 'default':
			self.destinationGroup = my.storageBuildingsWithSpace
		else:
			self.destinationGroup = destinationGroup

		self.bob = 10 # item will float up and down on the spot
		self.bobDir = 'up'
		self.reserved = None
		self.beingCarried = False
		self.lastCoords = None
		if self.sound and my.camera.isVisible(self.rect):
			sound.play(self.sound, 0.2)
Пример #8
0
    def checkForCollisions(self, data):
        shake = True
        collided = pygame.sprite.spritecollideany(self, data.destroyableEntities)
        if collided:
            collided.isBombed(data)  # tell the entity it has been bombed
            if collided in data.buildings:
                data.shakeScreen(20)
                shake = False

            if self in data.superBombs and isinstance(collided, Bullet):
                # super bombs go back upwards if shot
                if self.fallSpeed > 0:  # is falling
                    self.fallSpeed = -self.fallSpeed
                    self.baseImage = pygame.transform.rotate(self.baseImage, 180)

                    sound.play("plup", 0.8)
                    data.score += data.scoreValues["shoot superBomb"]
                return

            elif isinstance(collided, Bullet):
                data.score += data.scoreValues["shoot bomb"]

        if collided or self.rect.bottom > data.WINDOWHEIGHT:  # collided or touch bottom of screen
            self.explode(data, shake)
        elif self.rect.bottom < -20:  # out of sight at the top (disappear silently)
            self.kill()
            self.smoke.kill()

        if self in data.superBombs:
            collided = pygame.sprite.spritecollideany(self, data.superbombableEntities)
            if collided:
                collided.isBombed(data)
                self.explode(data, False)
Пример #9
0
 def at_beeper(self, x, y):
     '''Notifies interested parties about robot
     being at a beeper.
     '''
     onbeepersound = os.path.join(conf.getSettings().SOUNDS_DIR, 'beep.wav')
     if os.path.isfile(onbeepersound):
         play(onbeepersound)
Пример #10
0
    def special_fire(self, at):
        towards = helper.try_normalize(at.pos - self.pos)

        if self.get_stat("ship_take_damage_on_fire"):
            self.health -= self.get_stat("ship_take_damage_on_fire")

        b = Bullet(self.pos, at, self, mods=self.prepare_bullet_mods())
        self.scene.game_group.add(b)

        sound.play(random.choice(['laser1', 'laser2', 'laser3']))

        #self.velocity += -towards * 2
        self.pos += -towards * 1
        self.thrust_particle_time = THRUST_PARTICLE_RATE

        for i in range(10):
            pvel = helper.try_normalize(towards + V2(random.random() * 0.75,
                                                     random.random() * 0.75)
                                        ) * 30 * (random.random() + 0.25)
            p = Particle([
                PICO_WHITE, PICO_WHITE, PICO_BLUE, PICO_DARKBLUE, PICO_DARKBLUE
            ], 1, self.pos, 0.2 + random.random() * 0.15, pvel)
            self.scene.add_particle(p)

        self.bullets_chambered -= 1
Пример #11
0
    def on_button_order_clicked(self, widget, is_reverse = False):
        """单词显示顺序按钮
        is_reverse: 是否逆序显示
        """
        play("buttonactive")
        
        word_new_order = []
        for i in range(self.words_len):
            iter = self.liststore_recite.get_iter(i)
            word = self.liststore_recite.get_value(iter, COLUMN_WORD)
            word_new_order.append(word)

        word_old_order = word_new_order[:]
        
        if not is_reverse:
            word_new_order.sort()
        else:
            word_new_order.sort(reverse = True)

        new_order_map = []
        for word in word_new_order:
            new_order_map.append(word_old_order.index(word))

#         print word_old_order
#         print word_new_order
#         print new_order_map

        self.liststore_recite.reorder(new_order_map)            
	def updateWoodcutter(self, dt):
		if self.intention in [None, 'working'] and not self.chopping and my.tick[self.tick]:
			self.intention = 'working'
			self.findTree()

		if self.destinationSite and self.coords == self.destinationSite.coords:
			self.chopping = True
			self.thought = 'working'
			self.destinationSite.chop(dt)
			if self.animFrame != 6:
				self.chopSoundPlaying = False
			if self.animFrame == 6 and my.camera.isVisible(self.rect) and not self.chopSoundPlaying:
				num = randint(1, 2)
				sound.play('chop%s' %(num), 0.4)
				self.chopSoundPlaying = True
			if self.destinationSite.isDead:
				self.destinationSite = None
				self.intention, self.thought = None, None
				self.chopping = False
				if my.camera.isVisible(self.rect):
					sound.play('treeFalling', 0.3)

		else:
			self.chopping = False
			if self.animation not in [self.idleAnim, self.moveAnim]:
				self.animation = self.idleAnim
				self.animFrame = 0

		if self.chopping:
			self.destinationSite.reserved = self
			self.animation = Human.chopAnim
		self.lastSite = self.destinationSite
Пример #13
0
    def play_backspace_sound(self, widget, data=None):
        """播放退格声音或者错误提示音
        """
        if self.typing_sound:
            play("back")

        self.character_pos -= 1
Пример #14
0
    def fire(self, at):
        towards = helper.try_normalize(at.pos - self.pos)

        if self.get_stat("ship_take_damage_on_fire"):
            self.health -= self.get_stat("ship_take_damage_on_fire")

        b = Bullet(V2(self.pos), at, self, mods=self.prepare_bullet_mods())
        self.scene.game_group.add(b)

        #self.velocity += -towards * 2
        self.pos += -towards * 1.25
        self.thrust_particle_time = THRUST_PARTICLE_RATE

        sound.play(random.choice(['laser1', 'laser2', 'laser3']))

        for i in range(10):
            pvel = helper.try_normalize(towards + V2(
                (random.random() - 0.5) * 1.5,
                (random.random() - 0.5) * 1.5)) * 30 * (random.random() + 0.25)
            p = Particle([
                PICO_WHITE, PICO_WHITE, PICO_BLUE, PICO_DARKBLUE, PICO_DARKBLUE
            ], 1, V2(self.pos), 0.2 + random.random() * 0.15, pvel)
            self.scene.add_particle(p)

        self.need_attack_speed_particle = True
        self.attack_speed_particle_angle = towards.as_polar(
        )[1] * 3.14159 / 180
        self.stealth = False
Пример #15
0
    def play_backspace_sound(self, widget, data = None):
        """播放退格声音或者错误提示音
        """
        if self.typing_sound:
            play("back")

        self.character_pos -= 1
Пример #16
0
def main():

    # Поиск по заданным ключевым словам
    folder_name = input('Введите название папки: ')
    create_folder(folder_name)
    custom_search(input('Введите ключевые слова для поиска: '), folder_name)
    sound.play()
Пример #17
0
    def __init__(self, data, startAtLeft, yPos):
        pygame.sprite.Sprite.__init__(self)
        self.add(data.bombers)
        self.add(data.bulletproofEntities)
        self.add(data.superbombableEntities)

        self.imageL = data.loadImage("assets/enemies/bomber.png")
        self.imageR = pygame.transform.flip(self.imageL, 1, 0)

        self.droppedBomb = False
        self.timeTillBombPrimed = random.uniform(Bomber.minTimeToDropBomb, Bomber.maxTimeToDropBomb)
        self.lastBombDropTime = time.time()

        self.rect = self.imageR.get_rect()
        self.targetingRect = pygame.Rect((0, 0), (6, 10))  # BOMB SIZE

        self.smoke = SmokeSpawner(data, self.rect.topleft, 10)

        if startAtLeft:
            self.direction = "right"
            self.image = self.imageR
            self.rect.topright = (0, yPos)
        else:
            self.direction = "left"
            self.image = self.imageL
            self.rect.topleft = (data.WINDOWWIDTH, yPos)
        self.coords = list(self.rect.topleft)  # for more accurate positioning using floats

        sound.play("swoosh", 0.3)
Пример #18
0
 def move_tanks(self):
     any_steps = False
     for tank in self.scene.tanks:
         stepped = tank.tank_step(self.scene)
         any_steps = any_steps or stepped
     if any_steps:
         sound.play("tankdrive")
Пример #19
0
 def enter(self):
     self.defeat_image = pygame.image.load(
         resource_path("assets/defeat.png"))
     self.defeat_t = 0
     self.angle = 0
     self.scale = 0
     sound.play("defeat")
	def build(self, dt):
		"""If at site, construct it. If site is done, look for a new one."""
		done = False
		for site in my.buildingsUnderConstruction:
			for x in range(len(site.buildersPositions)):
				for y in range(len(site.buildersPositions[0])):
					if done: break
					if site.buildersPositionsCoords[x][y] == self.coords:
						self.building = site
						self.destinationSite = None
						self.building.buildProgress += my.CONSTRUCTIONSPEED * dt
						self.intention = 'working'
						done = True
					if done: break
				if done: break
		if not done:
			if self.animation not in [self.idleAnim, self.moveAnim]:
				self.animation = self.idleAnim
				self.animFrame = 0
			self.building = None
		else:
			if self.animation != Human.buildAnim:
				self.animation = Human.buildAnim
				self.animFrame = 0
			if self.animFrame != 6:
				self.buildSoundPlaying = False
			elif self.animFrame == 6 and my.camera.isVisible(self.rect) and not self.buildSoundPlaying:
				sound.play('hammering%s' %(randint(1, 6)))
				self.buildSoundPlaying = True
		if my.builtBuildings.has(self.building):
			self.building = None
			self.intention = None
Пример #21
0
    def __init__(self, data, startAtLeft, yPos):
        pygame.sprite.Sprite.__init__(self)
        self.add(data.bombers)
        self.add(data.bulletproofEntities)
        self.add(data.superbombableEntities)

        self.imageL = data.loadImage('assets/enemies/bomber.png')
        self.imageR = pygame.transform.flip(self.imageL, 1, 0)

        self.droppedBomb = False
        self.timeTillBombPrimed = random.uniform(Bomber.minTimeToDropBomb,
                                                 Bomber.maxTimeToDropBomb)
        self.lastBombDropTime = time.time()

        self.rect = self.imageR.get_rect()
        self.targetingRect = pygame.Rect((0, 0), (6, 10))  # BOMB SIZE

        self.smoke = SmokeSpawner(data, self.rect.topleft, 10)

        if startAtLeft:
            self.direction = 'right'
            self.image = self.imageR
            self.rect.topright = (0, yPos)
        else:
            self.direction = 'left'
            self.image = self.imageL
            self.rect.topleft = (data.WINDOWWIDTH, yPos)
        self.coords = list(
            self.rect.topleft)  # for more accurate positioning using floats

        sound.play('swoosh', 0.3)
Пример #22
0
    def update(self, dt, player):
        if player.grounded:
            if globals.keys[key.RIGHT] or globals.keys[key.LEFT]:
                player.dy = self.JUMP_DY
                sound.play('clunk.wav')

        super(SpringPlayerMovement, self).update(dt, player)
	def meleeAttack(self, target, damage, dt):
		self.justAttacked = True
		target.health -= (damage + randint(damage - damage / my.DAMAGEMARGIN, damage + damage / my.DAMAGEMARGIN)) * dt
		if target.health < 1:
			if self.weapon:
				target.causeOfDeath = 'slain by the %s of %s.' %(self.weapon.name, self.name)
			else:
				target.causeOfDeath = 'killed by %s.' %(self.name)
			self.animation = self.idleAnim
			self.animNum = 0
		else:
			try:
				if str(type(self.attackAnim)) == "<type 'dict'>":
					if target.rect.x > self.rect.x: facing = 'right'
					else: facing = 'left'
					self.animation = self.attackAnim[facing]

				else:
					self.animation = self.attackAnim
			except AttributeError:
				pass # has no attack animation

		if time.time() - self.lastAttackSoundTime > 1 and randint(0, 60)==0 and my.camera.isVisible(self.rect): # attack sounds
			if self.weapon and self.weapon.name == 'sword':
				sound.play('sword%s' %(randint(1, 4)))
			if not self.weapon:
				sound.play('punch%s' %(randint(1, 2)))
			self.lastAttackSoundTime = time.time()
Пример #24
0
	def __init__(self, text, highScore='do not display', score='do not display', isNewHighscore=False):
		self.playAgainText, self.playAgainRect = genText(text, (0, 0), ( 60,  60,  60), MenuScreen.instructionFont) # light grey
		self.playAgainAlpha = 0
		self.playAgainRect.midbottom = (WINDOWWIDTH / 2, WINDOWHEIGHT)
		self.playAgainTargetY = WINDOWHEIGHT / 2 + 20
		
		if highScore != 'do not display':
			sound.play('booshWhaWhaWhaWha')
			self.highScoreText, self.highScoreRect = genText('HIGH SCORE: ' + str(highScore), (0, 0), (255, 255, 102), MenuScreen.numberFont)
			self.highScoreRect.bottomleft = (WINDOWWIDTH / 2 + 20, 0)                                 # ^ yellow
		if score != 'do not display':
			self.scoreText, self.scoreRect = genText('LAST SCORE: ' + str(score), (0, 0), (255, 255, 102), MenuScreen.numberFont) # yellow
			self.scoreRect.bottomright = (WINDOWWIDTH / 2 - 20, 0)
			self.scoreRectsTargetY = WINDOWHEIGHT / 2 - 20

		if isNewHighscore:
			tempNewTextSurf, self.newTextRect = genText('NEW!', (0, 0), (250, 105, 97), MenuScreen.newHighscoreFont) # red
			tempNewTextSurf.convert_alpha()
			tempNewTextSurf = pygame.transform.rotate(tempNewTextSurf, -25)
			self.newTextSurf = pygame.Surface(tempNewTextSurf.get_size())
			self.newTextSurf.set_colorkey((0, 0, 0))
			self.newTextSurf.fill((135, 206, 250))
			self.newTextSurf.blit(tempNewTextSurf, (0,0))
		self.isNewHighscore = isNewHighscore

		self.keyboardImg = MenuScreen.keyboardImg.copy().convert_alpha()
		self.keyboardRect = MenuScreen.keyboardImg.get_rect()
		self.keyboardRect.midbottom = (WINDOWWIDTH / 2, WINDOWHEIGHT / 2 - 20)
Пример #25
0
 def update(self, dt, player):
     if player.grounded:
         if globals.keys[key.UP]:
             player.dy = self.JUMP_DY
             sound.play('clunk.wav')
     
     super(JumpPlayerMovement, self).update(dt, player)
Пример #26
0
def cicle():
    global timer_delay, timer_sound, opcode, pc
    # One emulation cicle

    #1 - Fetch Opcode
    """
    Merging two successive bytes to form the opcode

    memory.(!pc)     = 00000000 10100010
    memory.(!pc + 1) = 00000000 11110000

    a) shift the top 8 bits
    10100010 << 8    = 10100010 00000000

    b) merge the two bytes
    10100010 00000000 | 
    00000000 11110000
    -------------------
    10100010 11110000

  """
    opcode = (mem.memory[pc] << 8) | mem.memory[pc + 1]

    # 2 - Decode and Execute Opcode
    decode(opcode)

    # 3 - Update timers
    if timer_delay > 0: timer_delay -= 1

    if timer_sound > 0:
        if timer_sound == 1: sound.play()

        timer_sound -= 1
Пример #27
0
    def interact(self, state, worker):
        soldier_group = self.find_contiguous_soldiers(state.scene)

        enough_workers = True
        snake_poss = [(s.gx, s.gy) for s in state.scene.snake]
        for s in soldier_group:
            any_worker_neighbor = False
            for nx, ny in s.get_neighbors(state.scene):
                if (nx, ny) in snake_poss:
                    any_worker_neighbor = True
                    s.state = "disarm"
                    s.state_time = 0.5
                    dx = nx - s.gx
                    dy = ny - s.gy
                    s.last_move_direction = game.DIRS_FROM_OFFSETS[(dx, dy)]
            if not any_worker_neighbor:
                enough_workers = False

        if len(state.scene.snake) < len(soldier_group):
            enough_workers = False

        if enough_workers:
            sound.play("soldier")
            for s in soldier_group:
                state.scene.object_grid[s.gy][s.gx] = None
                state.scene.add_queued_worker()
                state.scene.animatedsprites.remove(s)
                s.state = "won"
                s.state_time = 0.2
        else:
            sound.play("cannot")
Пример #28
0
    def __init__(self, pos, velocity, shooter):
        pygame.sprite.Sprite.__init__(self)
        my.ENGINE.game.entities.add(self)
        my.ENGINE.game.entities.setTarget(self)

        self.image = IMAGES['default_bullet']
        if velocity.x < 0:
            self.image = pygame.transform.flip(self.image, True, False)
        if velocity.y > -6:
            self.image = pygame.transform.flip(self.image, False, True)
        self.original = self.image.copy()

        self.pos = [
            pos[0] +
            (self.image.get_width() if pygame.mouse.get_pos()[0] > pos[0] else
             -self.image.get_width()), pos[1]
        ]
        self.rect = self.image.get_rect(center=self.pos)
        self.rect.x += self.rect.w if pygame.mouse.get_pos(
        )[0] > pos[0] else -self.rect.w

        self.velocity = velocity
        self.shooter = shooter
        self.firing = True
        self.DAMAGE = random.randrange(15, 20)

        sound.play('launch')
Пример #29
0
 def cake_time(self, dt=None):
     globals.game.clock.schedule_once(self.start_rocket_time, 1.5)
     self.placed = placeable.get_placeable('cake.png', 1,
                                           1).place(self.x - 200,
                                                    self.y + 100)
     globals.game.effects_layer.add_placed(self.placed)
     sound.play('bleep.wav')
Пример #30
0
    def __init__(self,
                 name,
                 quantity,
                 coords,
                 destinationGroup='default',
                 imageName=None):
        """imageName need only be specified if it's not the same as the item name"""
        pygame.sprite.Sprite.__init__(self)
        self.add(my.allItems)
        self.add(my.itemsOnTheFloor)
        self.name, self.quantity, self.coords = name, quantity, coords
        self.rect = pygame.Rect(my.map.cellsToPixels(self.coords),
                                (my.CELLSIZE, my.CELLSIZE))

        if not imageName:
            imageName = self.name
        self.image = Item.IMG[imageName]
        self.carryImage = pygame.transform.scale(self.image, (10, 10))

        if destinationGroup == 'default':
            self.destinationGroup = my.storageBuildingsWithSpace
        else:
            self.destinationGroup = destinationGroup

        self.bob = 10  # item will float up and down on the spot
        self.bobDir = 'up'
        self.reserved = None
        self.beingCarried = False
        self.lastCoords = None
        if self.sound and my.camera.isVisible(self.rect):
            sound.play(self.sound, 0.2)
Пример #31
0
 def mouse_input(self, input, event):
     if input == "click":
         pr = pygame.Rect(self.panel.x, self.panel.y, self.panel.width,
                          self.panel.height)
         if not pr.collidepoint(event.gpos):
             sound.play("cancel")
             self.scene.sm.transition(PlayState(self.scene))
     return super().mouse_input(input, event)
Пример #32
0
 def play_backspace_sound(self, widget, data=None):
     """播放退格声音或者错误提示音
     """
     if self.typing_sound:
         if not self.entry_word.get_editable():
             play("answerno")
         else:
             play("back")
Пример #33
0
def pressed():
    if throttle.check():
        log.info('Doorbell pressed')
        sound.play()
        pushover.send(config.message_text)
        thingspeak.update()
    else:
        log.info('THROTTLING')
Пример #34
0
def unbuild(structure):
	if structure is hq or structure in artifacts:
		sound.play("error")
		return
	structures.remove(structure)
	structure.alive = False
	effects.append(things.Explosion(structure.u, structure.f))
	updatenetwork()
Пример #35
0
 def play_backspace_sound(self, widget, data = None):
     """播放退格声音或者错误提示音
     """
     if self.typing_sound:
         if not self.entry_word.get_editable():
             play ("answerno")
         else:
             play("back")
Пример #36
0
def func(txt3):
    txt = "hello "
    txt2 = " . Please let me read your emotions"
    tts = gTTS(text=txt + txt3 + txt2, lang='en')
    tts.save("hello.mp3")
    os.remove('welcome.wav')
    os.system("ffmpeg -i hello.mp3 welcome.wav ")
    sound.play('welcome.wav')
Пример #37
0
 def interact(self, state, worker):
     if not self.activated:
         state.scene.add_queued_worker()
         self.activated = True
         self._frame = 3
         self._update_image()
         sound.play("factory")
     return False
Пример #38
0
 def buy(self, cname):
     cost = settings.modulecosts[cname]
     if self.bank < cost:
         sound.play("cantbuy")
         return
     self.unused[cname] += 1
     self.bank -= cost
     sound.play("buy")
Пример #39
0
def tess(image):
    #while not info_signal_queue.empty():
    #        getimage = signalerkennung.info_signal_queue.get()
    image_string = pytesseract.image_to_string(image, config='--oem 0 --psm 5')
    detected_number = re.search('\d+', image_string)[0]
    print(detected_number)
    sound.play(str(detected_number))
    return detected_number
Пример #40
0
    def select_1_player(self):
        sound.play("oneplayer")
        unregister_event(KEYDOWN, self.select_1_player , K_1)
        unregister_event(KEYDOWN, self.select_2_players , K_2)

        self.players = 1

        self.draw_select_mode_screen()
Пример #41
0
	def buy(self, cname):
		cost = settings.modulecosts[cname]
		if self.bank < cost:
			sound.play("cantbuy")
			return
		self.unused[cname] += 1
		self.bank -= cost
		sound.play("buy")
Пример #42
0
 def play_type_sound(self,
                     widget,
                     new_text,
                     new_text_length,
                     position,
                     data=None):
     if not self.is_new_word and self.typing_sound:  # 不播放回车的声音
         play("type")
Пример #43
0
def on_message(ws, message):
    obj = json.loads(message)
    if obj.has_key('callsign'):
        global my_callsign
        my_callsign = obj['callsign']
    if obj.has_key('signal'):
        signal = obj['signal']
        if signal: sound.play()
        else: sound.stop()
Пример #44
0
    def on_button_shuffle_clicked(self, widget, data = None):
        """随机乱序按钮
        """
        play("buttonactive")
        shuffle_order = range(self.words_len)

        random.shuffle(shuffle_order)
        
        self.liststore_recite.reorder(shuffle_order)
Пример #45
0
 def update(self, dt, keys):
     if self.t < len(self.sound_data):
         self.t += int(dt * sound.SAMPLE_FREQ)
         self.array = np.append(self.array,
                                self.sound_data[self.last:self.t] * 100)
         self.last = self.t
     if self.plast < len(self.sound_data) - 1:
         sound.play(self.sound_data[self.plast:])
         self.plast = len(self.sound_data) - 1
Пример #46
0
 def __play_cb(self, widget, playButtonImg, pauseButtonImg):
     if widget.get_active():
         widget.set_icon_widget(pauseButtonImg)
         sound.play()
         self.montage.play()
     else:
         widget.set_icon_widget(playButtonImg)
         sound.stop()
         self.montage.stop()
Пример #47
0
    def joystick_input(self, input, event):
        if input == "back":
            sound.play("cancel")
            self.scene.sm.transition(PlayState(self.scene))

        if input == "confirm":
            sound.play("click1")
            self.panel.on_launch_click()
        return super().joystick_input(input, event)
Пример #48
0
def idleFunc():
    global frame
    global starttime
    global basetime
    global time
    global fps

    global startcycle
    global stop

    if not stop:
        # Draw current frame
        glutPostRedisplay()

        elapsed_time = glutGet(GLUT_ELAPSED_TIME)

        startcycle = time
        if frame == 0:
            starttime = elapsed_time
            basetime = elapsed_time
            time = starttime
            fps = 0
        else:
            if not paused:
                time = elapsed_time - starttime
            else:
                starttime = elapsed_time - time
            if (elapsed_time - basetime > 1000):
                fps = int(round(frame * 1000 / (elapsed_time - basetime)))
                basetime = elapsed_time
                frame = 0
            if time >= totaltime:
                time = totaltime
                stop = True
            if not paused:
                cyclesuccess, crashedarms = cycle.run(arms, strikers,
                                                      strikercommands,
                                                      startcycle, time,
                                                      numberofnotes, notelist,
                                                      offset, midifilename)
                # Play hit notes
                for notehit in cycle.notehits:
                    if not notehit[2]:
                        # Hitvel is yet to be implemented, assign a static 127
                        sound.play(notehit[0], 127)
                        notehit[2] = True
                if not cyclesuccess:
                    gui.arm.crashedarms = crashedarms
                    stop = True
                    glutPostRedisplay()
                    log.close()
                else:
                    if time == totaltime:
                        log.info('Simulation successful')
                        log.close()
    frame += 1
Пример #49
0
def shoot(shooter, Projectile, pos, direction, speed = 5):
    sound.play("harpoon")
    direction.module = 1
    pos += direction

    ent = Projectile(pos = pos, direction = direction,
                     speed = direction * speed, shooter = shooter)

    game = app.get_current_game()
    game.projectiles.add(ent)
Пример #50
0
    def isBombed(self, data):
        """Called when a superbomb hits the bomber"""
        self.kill()
        self.smoke.kill()
        Explosion(data, self.rect.center, 60)
        data.shakeScreen(20)
        sound.play("shoot down")
        pygame.time.wait(50)

        data.score += data.scoreValues["destroy bomber"]
Пример #51
0
	def update(self, game):
		if self.key in game.input.justPressedKeys and not self.isDead and not game.gameOver:
			self.jump()
			if not self.hasJumped:
				self.hasJumped = True
				self.add(game.activeBirds)
				self.surf = self.circleSurf.copy()
				self.maxAlpha = 255

		if (not self.hasJumped and time.time() - self.birthTime > Bird.timeTillCompulsaryJump) or (game.gameOver and not self.isDead):
			self.hasJumped = True  # start falling
			self.surf = self.circleSurf.copy()

		if self.hasJumped:
			self.updateYPosition(game)
			self.surf.set_alpha(255)
		else:
			self.maxAlpha = 80
			if time.time() - self.birthTime > Bird.timeTillCompulsaryJump - 1.3:
				self.surf.blit(self.redCircle, (0, 0))

		if not self.isDead:
			if not game.WINDOWRECT.collidepoint(self.rect.midtop) or not game.WINDOWRECT.collidepoint(self.rect.midbottom):
				if not game.WINDOWRECT.collidepoint(self.rect.midtop):
					self.velocity = 0
				elif not game.WINDOWRECT.collidepoint(self.rect.midbottom):
					self.velocity = 5

				self.xVelocity = random.randint(-700, 700)
				self.isDead = True
				self.surf.blit(self.fadedCircle, (0,0))
				sound.play('shatter')

		if self.isDead:
			if self.key not in game.inactiveKeys:
				game.inactiveKeys.append(self.key)
			self.remove(game.activeBirds)
			if self.rect.top > game.WINDOWRECT.bottom:
				self.kill()
			else:
				self.rect.x += self.xVelocity * game.dt
				
				modifier = -1
				if self.xVelocity < 0:
					modifier = 1
				self.xVelocity += modifier

		if not self.hasJumped and self.alpha < self.maxAlpha:
			self.alpha += 1
			self.surf.set_alpha(self.alpha)

		if time.time() - self.lastIncrementScoreTime > game.INCREMENTSCOREINTERVAL and self.hasJumped and not self.isDead:
			game.score += 1

		screen.blit(self.surf, self.rect)
Пример #52
0
	def __init__(self, data, pos, aimAt):
		pygame.sprite.Sprite.__init__(self)
		self.add(data.bullets)
		self.add(data.destroyableEntities)  # explode bombs it comes into contact with

		self.image = Bullet.image
		self.rect = self.image.get_rect(center=pos)
		self.coords = [float(self.rect.centerx), float(self.rect.centery)]
		self.angle = self.get_angle(pos, aimAt)

		sound.play('shoot%s' %(random.randint(1, 2)), 0.4)
Пример #53
0
 def hit(self, placed, cell):
     super(TallyPlaceable, self).hit(placed, cell)
     globals.game.incr_tally(self.tally)
     x = placed.x + placed.placeable.width // 2
     y = placed.y + placed.placeable.height // 2
     if self.tally == 'box':
         globals.game.add_effect(particles.purple_star_effect, x, y)
     else:
         globals.game.add_effect(particles.star_effect, x, y)
     if self.sound:
         sound.play(self.sound)
Пример #54
0
	def unlock(self, modulename):
		if modulename not in self.available or modulename in self.unlocked:
			return
		cost = settings.modulecosts[modulename]
		if self.bank < cost:
			sound.play("cantbuy")
			return
		self.unlocked.append(modulename)
		self.unused[modulename] = 1
		self.bank -= cost
		sound.play("buy")
def listener(value, socketIO):

    if (this.oldtimeRFID + 5 < int(time())):
        this.oldtimeRFID = int(time())
        # lire le son RFID
        SOUND.play("rfid")
        LED.playAnimation(1)

        # envoyer les valeurs au serveur
        socketIO.emit("rfid", value)
    else:
        print "EN ATTENTE RFID"
Пример #56
0
	def think(self, dt):
		self.t += dt
		while self.t > self.shoottime:
			self.t -= self.shoottime
			self.zeta += math.tau / 1.618
			self.launchslug(6, self.zeta)
			self.launchslug(6, self.zeta + math.tau / 3)
			self.launchslug(6, self.zeta + 2 * math.tau / 3)
			sound.play("shoot")
		if self.target is None or math.sqrt((self.x - self.target[0]) ** 2 + (self.y - self.target[1]) ** 2) < 1:
			self.pickrandomtarget(self.pos0, 6)
		Boss.think(self, dt)
Пример #57
0
 def drown_player(self):
     if self.player.dead:
         return
     if _debug:
         print 'Player drowned!'
     self.player.movement = player.drown_movement
     x = self.player.x
     bb = self.player.get_bbox()
     y = (bb.y2 + bb.y1) // 2
     self.add_effect(particles.bubble_effect, x, y)
     self.kill_player()
     sound.play('bubbles.wav')
Пример #58
0
 def play_segs(self, k):
     """
     Play audio segments corresponding to cluster k (zero-based index)
     """
     if k is None:
         raise TypeError("play_segs requires an integrer cluster index: k")
     clusters = self.assigns[self.diffs[:-1]]
     sr = self.feature.sample_rate
     for seg in np.where(clusters==k)[0]:
         print self.segmentation[seg]
         x = sound.wavread(self.media, first=int(self.segmentation[seg].time_span.start_time*sr), last=int(self.segmentation[seg].time_span.duration*sr))
         sound.play(x[0].T, sr)