本文整理汇总了Python中sound.play函数的典型用法代码示例。如果您正苦于以下问题:Python play函数的具体用法?Python play怎么用?Python play使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了play函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: update
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)
开发者ID:italomaia,项目名称:turtle-linux,代码行数:7,代码来源:player.py
示例2: checkForCollisions
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)
开发者ID:strin,项目名称:curriculum-deep-RL,代码行数:33,代码来源:object.py
示例3: at_beeper
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)
开发者ID:josdie,项目名称:play-to-program,代码行数:7,代码来源:robot_factory.py
示例4: meleeAttack
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()
开发者ID:VivekRajagopal,项目名称:Aedificus---Fathers_of_Rome,代码行数:28,代码来源:mob.py
示例5: __init__
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)
开发者ID:VivekRajagopal,项目名称:Aedificus---Fathers_of_Rome,代码行数:25,代码来源:item.py
示例6: on_button_order_clicked
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)
开发者ID:kansifang,项目名称:wordjoy,代码行数:28,代码来源:recite.py
示例7: play_backspace_sound
def play_backspace_sound(self, widget, data = None):
"""播放退格声音或者错误提示音
"""
if self.typing_sound:
play("back")
self.character_pos -= 1
开发者ID:kansifang,项目名称:wordjoy,代码行数:7,代码来源:type.py
示例8: build
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
开发者ID:VivekRajagopal,项目名称:Aedificus---Fathers_of_Rome,代码行数:32,代码来源:mob.py
示例9: updateWoodcutter
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
开发者ID:VivekRajagopal,项目名称:Aedificus---Fathers_of_Rome,代码行数:32,代码来源:mob.py
示例10: toggle_paused
def toggle_paused(self):
self.paused = not self.paused
if self.paused:
sound.pause_music()
else:
sound.resume_music()
sound.play("pause")
开发者ID:kms70847,项目名称:Falling-Block-Game,代码行数:7,代码来源:gameDisplay.py
示例11: __init__
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)
开发者ID:strin,项目名称:curriculum-deep-RL,代码行数:29,代码来源:object.py
示例12: __init__
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)
开发者ID:jellyberg,项目名称:Juggleball,代码行数:28,代码来源:libengine.py
示例13: pressed
def pressed():
if throttle.check():
log.info('Doorbell pressed')
sound.play()
pushover.send(config.message_text)
thingspeak.update()
else:
log.info('THROTTLING')
开发者ID:viv,项目名称:pibell,代码行数:8,代码来源:button.py
示例14: unbuild
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()
开发者ID:cosmologicon,项目名称:unifac,代码行数:8,代码来源:state.py
示例15: play_backspace_sound
def play_backspace_sound(self, widget, data = None):
"""播放退格声音或者错误提示音
"""
if self.typing_sound:
if not self.entry_word.get_editable():
play ("answerno")
else:
play("back")
开发者ID:kansifang,项目名称:wordjoy,代码行数:8,代码来源:spellingtest.py
示例16: select_1_player
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()
开发者ID:MobiusFreak,项目名称:WhaleGame,代码行数:8,代码来源:menu.py
示例17: buy
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")
开发者ID:cosmologicon,项目名称:unifac,代码行数:8,代码来源:state.py
示例18: on_message
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()
开发者ID:Zhdat,项目名称:ChatMorse,代码行数:9,代码来源:client.py
示例19: on_button_shuffle_clicked
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)
开发者ID:kansifang,项目名称:wordjoy,代码行数:9,代码来源:recite.py
示例20: shoot
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)
开发者ID:MobiusFreak,项目名称:WhaleGame,代码行数:10,代码来源:projectile.py
注:本文中的sound.play函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论