当前位置: 首页>>代码示例>>Python>>正文


Python simplegui.load_sound函数代码示例

本文整理汇总了Python中simplegui.load_sound函数的典型用法代码示例。如果您正苦于以下问题:Python load_sound函数的具体用法?Python load_sound怎么用?Python load_sound使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了load_sound函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: loadSounds

def loadSounds():
    global matchSound
    global failSound
    global victorySound
    matchSound = simplegui.load_sound(GAME_ASSETS + "win.ogg")
    failSound = simplegui.load_sound(GAME_ASSETS + "lose.ogg")
    victorySound = simplegui.load_sound(GAME_ASSETS + "goal.ogg")
开发者ID:mwales,项目名称:education,代码行数:7,代码来源:game.py

示例2: __init__

 def __init__(self, url):
     self.url = url
     if CACHE_STORE.has_key(url):
         self.sound = CACHE_STORE[url]
     else:
         self.sound = simplegui.load_sound(url)
         CACHE_STORE[url] = self.sound
开发者ID:vutran,项目名称:asteroids,代码行数:7,代码来源:game.py

示例3: __init__

 def __init__(self):
     self.center_x = 99
     self.center_y = 260
     self.speed = 0
     self.gravity = 0
     self.image = simplegui.load_image(BIRD_IMAGE)
     self.flap_sound = simplegui.load_sound(FLAP_SOUND)
开发者ID:zincsoda,项目名称:flappy_bird,代码行数:7,代码来源:7_create_and_remove_pipes.py

示例4: __init__

 def __init__(self, pos, vel, angle, image, info, BOARD_WIDTH, BOARD_HEIGHT):
     self.pos = [pos[0], pos[1]]
     self.vel = [vel[0], vel[1]]
     self.thrust = False
     self.angle = angle
     self.angle_vel = 0
     self.FRICTION = 0.009
     self.BOARD_WIDTH = BOARD_WIDTH
     self.BOARD_HEIGHT = BOARD_HEIGHT
     self.MISSILE_SPEED = 7
     self.image = image
     self.image_center = info.get_center()
     self.image_size = info.get_size()
     self.radius = info.get_radius()
     self.timer = None
     self.time_passed = 0.0
     self.ship_thrust_sound = simplegui.load_sound("http://commondatastorage.googleapis.com/codeskulptor-assets/sounddogs/thrust.mp3")
     self.missile_info = ImageInfo([5, 5], [10, 10], 3, 40)
     self.missile_image = simplegui.load_image("http://commondatastorage.googleapis.com/codeskulptor-assets/lathrop/shot2.png")
     self.missile_sound = simplegui.load_sound("http://commondatastorage.googleapis.com/codeskulptor-assets/sounddogs/missile.mp3")
     self.missile_sound.set_volume(.7)
开发者ID:phaedraa,项目名称:Games,代码行数:21,代码来源:Asteroids.py

示例5: __init__

    def __init__(self):
        self.my_ship = Ship([WIDTH / 2, HEIGHT / 2], [0, 0], 0)
        self.rock_group = set()
        self.explosion_group = set()

        self.lives = 3
        self.started = False
        self.score = 0
        self.time = 0.5
        self.max_rock_velocity = 10
        self.points_to_velocity_map = {
            20: 13, 30: 17, 40: 21, 50: 25, 60: 29, 70: 33, 80: 37,
            90: 41, 100: 45
        }

        self.soundtrack = simplegui.load_sound(
            MEDIA_HOST + 'sounddogs/soundtrack.mp3')
        self.splash_info = ImageInfo([200, 150], [400, 300])
        self.splash_image = simplegui.load_image(
            MEDIA_HOST + 'lathrop/splash.png')
        self.asteroid_info = ImageInfo([45, 45], [90, 90], 40)
        self.asteroid_image = simplegui.load_image(
            MEDIA_HOST + 'lathrop/asteroid_blue.png')
        self.ship_explosion_image = simplegui.load_image(
            MEDIA_HOST + 'lathrop/explosion_alpha.png')
        self.asteroid_explosion_image = simplegui.load_image(
            MEDIA_HOST + 'lathrop/explosion_blue2.png')
        self.ship_thrust_sound = simplegui.load_sound(
            MEDIA_HOST + 'sounddogs/thrust.mp3')
        self.explosion_info = ImageInfo([64, 64], [128, 128], 17, 24, True)
        self.explosion_sound = simplegui.load_sound(
            MEDIA_HOST + 'sounddogs/explosion.mp3')
        self.debris_info = ImageInfo([320, 240], [640, 480])
        self.debris_image = simplegui.load_image(
            MEDIA_HOST + 'lathrop/debris3_brown.png')
        self.nebula_info = ImageInfo([400, 300], [800, 600])
        self.nebula_image = simplegui.load_image(
            MEDIA_HOST + 'lathrop/nebula_blue.s2014.png')
开发者ID:wisienka91,项目名称:asteroids,代码行数:38,代码来源:asteroids.py

示例6: __init__

    def __init__(self, size, radius = 0, lifespan = float('inf'), sound_url = None):
        """All the resuable data

        :size:      @ output size of image
        :radius:    @ for collision determination
        :lifespan:  @ automatically disappear if not infinite, count in drawing frames
        :sound_url: @ sound file url

        """
        self.size     = size
        self.radius   = radius
        self.lifespan = lifespan

        self.sound = simplegui.load_sound(sound_url) if sound_url else None
开发者ID:jjliun,项目名称:Python,代码行数:14,代码来源:spaceship2.py

示例7: __init__

 def __init__(self, pos, vel, angle, image, info):
     self.pos = [pos[0],pos[1]]
     self.vel = [vel[0],vel[1]]
     self.thrust = False
     self.angle = angle
     self.angle_vel = 0
     self.image = image
     self.image_center = info.get_center()
     self.image_size = info.get_size()
     self.radius = info.get_radius()
     self.ANGULAR_VEL_CHANGE = 0.10
     self.info = info
     
     self.ship_thrust_sound = simplegui.load_sound("http://commondatastorage.googleapis.com/codeskulptor-assets/sounddogs/thrust.mp3")
     self.ship_thrust_sound.set_volume(1)
     
     self.friction_constant = SHIP_FRICTION_CONSTANT
开发者ID:deltaworld,项目名称:python-programming-coursera,代码行数:17,代码来源:mini-project+-+Student+4.py

示例8: init

def init():
    global paddle1_pos, paddle2_pos, paddle1_vel, paddle2_vel, message  # these are floats
    global score1, score2  # these are ints
    restart = simplegui.load_sound("http://www.mediacollege.com/downloads/sound-effects/star-wars/yoda/yoda_doordonot.wav")
    restart.play()
    paddle1_pos = (HEIGHT-PAD_HEIGHT)/2
    paddle2_pos = (HEIGHT-PAD_HEIGHT)/2
    paddle1_vel = 0
    paddle2_vel = 0
    score1 = 0
    score2 = 0
    message = ""
    start_serve = random.randrange(0,2)
    if (start_serve == 0):
        ball_init(False)
    else:
        ball_init(True)
开发者ID:GJena,项目名称:Games,代码行数:17,代码来源:pong.py

示例9: load

    def load(self):
        """
        **Start loading** of all images and sounds added
        since last `Loader.load()` execution.

        * In standard Python with SimpleGUICS2Pygame:
        draw a progression bar on canvas
        and wait until the loading is finished.

        * In SimpleGUI of CodeSkulptor: *don't* wait.
        """
        try:
            from simplegui import load_image, load_sound

            SIMPLEGUICS2PYGAME = False
        except ImportError:
            from SimpleGUICS2Pygame.simpleguics2pygame import load_image, \
                load_sound

            SIMPLEGUICS2PYGAME = True

        self._SIMPLEGUICS2PYGAME = SIMPLEGUICS2PYGAME

        if SIMPLEGUICS2PYGAME:
            handler_saved = self._frame._canvas._draw_handler
            self._frame._canvas._draw_handler = self._draw_loading

        for name in self._sounds:
            if SIMPLEGUICS2PYGAME:
                self._frame._canvas._draw()
            if isinstance(self._sounds[name], str):
                self._sounds[name] = load_sound(self._sounds[name])

        for name in self._images:
            if SIMPLEGUICS2PYGAME:
                self._frame._canvas._draw()
            if isinstance(self._images[name], str):
                self._images[name] = load_image(self._images[name])

        if SIMPLEGUICS2PYGAME:
            self._frame._canvas._draw()
            self._frame._canvas._draw_handler = handler_saved
开发者ID:moehuster,项目名称:python,代码行数:42,代码来源:simplegui_lib_loader.py

示例10: draw

def draw(canvas):
    """
    Print str representation of each SimpleGUI object.

    :param canvas: simpleguics2pygame.Canvas or simplegui.Canvas
    """
    image = simplegui.load_image('')
    sound = simplegui.load_sound('')
    timer = simplegui.create_timer(1000, lambda: None)

    for name, o in (('button', button),
                    ('canvas', canvas),
                    ('frame',  frame),
                    ('image',  image),
                    ('input',  input),
                    ('label',  label),
                    ('sound',  sound),
                    ('timer',  timer)):
        print(name + str(type(o)) + repr(o) + str(o))

    frame.stop()
开发者ID:Yesterday69,项目名称:Django-blog,代码行数:21,代码来源:test_objects.py

示例11: ImageInfo

ship_image = simplegui.load_image("http://commondatastorage.googleapis.com/codeskulptor-assets/lathrop/double_ship.png")

# missile image - shot1.png, shot2.png, shot3.png
missile_info = ImageInfo([5,5], [10, 10], 3, 75)
missile_image = simplegui.load_image("http://commondatastorage.googleapis.com/codeskulptor-assets/lathrop/shot2.png")

# asteroid images - asteroid_blue.png, asteroid_brown.png, asteroid_blend.png
asteroid_info = ImageInfo([45, 45], [90, 90], 40)
asteroid_image = simplegui.load_image("http://commondatastorage.googleapis.com/codeskulptor-assets/lathrop/asteroid_blue.png")

# animated explosion - explosion_orange.png, explosion_blue.png, explosion_blue2.png, explosion_alpha.png
explosion_info = ImageInfo([64, 64], [128, 128], 17, 24, True)
explosion_image = simplegui.load_image("http://commondatastorage.googleapis.com/codeskulptor-assets/lathrop/explosion_alpha.png")

# sound assets purchased from sounddogs.com, please do not redistribute
soundtrack = simplegui.load_sound("http://commondatastorage.googleapis.com/codeskulptor-assets/sounddogs/soundtrack.mp3")
missile_sound = simplegui.load_sound("http://commondatastorage.googleapis.com/codeskulptor-assets/sounddogs/missile.mp3")
missile_sound.set_volume(.5)
ship_thrust_sound = simplegui.load_sound("http://commondatastorage.googleapis.com/codeskulptor-assets/sounddogs/thrust.mp3")
explosion_sound = simplegui.load_sound("http://commondatastorage.googleapis.com/codeskulptor-assets/sounddogs/explosion.mp3")

## CC 3.0 sound file by Jesus Lastra, http://opengameart.org/content/8-bit-pickup-1
extra_life_sound = simplegui.load_sound("http://mwales.net/junk/SFX_Pickup_44.mp3")

# helper functions to handle transformations
def angle_to_vector(ang):
    return [math.cos(ang), math.sin(ang)]

def vector_to_angle(v):
    return math.atan2(v[0],v[1])
开发者ID:mwales,项目名称:education,代码行数:30,代码来源:asteroids.py

示例12:

# project - Blackjack

import simplegui
import random

# load card sprite - 949x392 - source: jfitz.com
CARD_SIZE = (73, 98)
CARD_CENTER = (36.5, 49)
card_images = simplegui.load_image("http://commondatastorage.googleapis.com/codeskulptor-assets/cards.jfitz.png")
button_not_working = simplegui.load_sound("https://www.dropbox.com/s/fyd6o2bu2fq5v3g/button%20not%20working.ogg?dl=1")
won_game = simplegui.load_sound("https://www.dropbox.com/s/um0decuhbs5ljd9/won.ogg?dl=1")
deal_new_card = simplegui.load_sound("https://www.dropbox.com/s/47zech3mdxs4nzx/deal_card.ogg?dl=1")
deal_new_card.set_volume(0.3)

CARD_BACK_SIZE = (71, 96)
CARD_BACK_CENTER = (35.5, 48)
card_back = simplegui.load_image("http://commondatastorage.googleapis.com/codeskulptor-assets/card_back.png")    

# initialize some useful global variables
in_play = False
outcome = ""
score = 0

# define globals for cards
SUITS = ('C', 'S', 'H', 'D')
RANKS = ('A', '2', '3', '4', '5', '6', '7', '8', '9', 'T', 'J', 'Q', 'K')
VALUES = {'A':1, '2':2, '3':3, '4':4, '5':5, '6':6, '7':7, '8':8, '9':9, 'T':10, 'J':10, 'Q':10, 'K':10}


# define card class
class Card:
开发者ID:aman400,项目名称:Blackjack,代码行数:31,代码来源:Blackjack.py

示例13: str

    music.set_volume(vol / 10.0)
    volume_button.set_text("Volume = " + str(vol))


# create frame - canvas will be blank
frame = simplegui.create_frame("Music demo", 250, 250, 100)

# set up control elements 
frame.add_button("play", play,100)
frame.add_button("pause", pause,100)
frame.add_button("rewind",rewind,100)
frame.add_button("laugh",laugh,100)
frame.add_button("Vol down", vol_down,100)
frame.add_button("Vol up", vol_up,100)

# initialize volume, create button whose label will display the volume
vol = 7
volume_button = frame.add_label("Volume = " + str(vol))


# load some sounds
music = simplegui.load_sound("http://commondatastorage.googleapis.com/codeskulptor-assets/Epoq-Lepidoptera.ogg")
laugh = simplegui.load_sound("http://commondatastorage.googleapis.com/codeskulptor-assets/Evillaugh.ogg")

# make the laugh quieter so my ears don't bleed
laugh.set_volume(.1)

frame.start()


开发者ID:Crescent-Saturn,项目名称:Hello_Python,代码行数:28,代码来源:exemples-sound.py

示例14: D

import simplegui as S,math as M,random as R
_="_blue"
y="http://commondatastorage.googleapis.com/codeskulptor-assets/"
j=y+"sounddogs/"
q=y+"lathrop/"
z=m=t=s=0
W=800
H=600
C=[W/2,H/2]
l=3
Z=[0,1]
L=lambda s:S.load_image(s+".png")
O=lambda s:S.load_sound(s)
r=lambda a,b:R.random()*(b-a)+a
A=lambda a:[M.cos(a),M.sin(a)]
h=O(j+"thrust.mp3")
def D(a,b,c,d,e,f,g=0):a.draw_image(b,c,d,e,f,g)
class I:
 def __init__(s,c,z,r=0,l=0,a=0):s.c=c;s.z=z;s.r=r;s.a=a;s.l=l if l else float('inf')
class X:
 def __init__(s,p,v,a,g,i,n,d=0):
  s.p=p;s.v=v;s.a=a;s.g=g;s.i=i;s.c=n.c;s.z=n.z;s.r=n.r
  if d:d.rewind();d.play()
 def d(s,c,a=0):D(c,s.i,[s.c[0]+a,s.c[1]],s.z,s.p,s.z,s.a)
 def w(s):s.a+=s.g;s.p[1]+=s.v[1];s.p[0]+=s.v[0];s.p[0]%=W;s.p[1]%=H
class T(X):
 def __init__(s,p,v,a,i,n):X.__init__(s,p,v,0,0,i,n);s.t=0
 def e(s):s.t=1-s.t;[h.rewind,h.play][s.t]()
 def f(a):
  global z;k=A(a.a);p=a.p[:];v=a.v[:]
  for i in Z:p[i]+=40*k[i];v[i]+=8*k[i]
开发者ID:tpowellcio,项目名称:pylearn,代码行数:31,代码来源:SpaceshipSmall.py

示例15:

# define timers
timer = simplegui.create_timer(stopwatch_interval, tick)
message_colour_timer = simplegui.create_timer(colour_interval, message_colour_tick)
message_blink_timer = simplegui.create_timer(blink_interval, message_blink_tick)
music_timer = simplegui.create_timer(music_interval, music_tick)

# load graphics
background = simplegui.load_image("http://www.chloeunrau.com/stuff/es-c.jpg")
cheevo5 = simplegui.load_image("http://www.chloeunrau.com/stuff/es-5a.jpg")
cheevo10 = simplegui.load_image("http://www.chloeunrau.com/stuff/es-10a.jpg")
cheevo25 = simplegui.load_image("http://www.chloeunrau.com/stuff/es-25a.jpg")
cheevo50 = simplegui.load_image("http://www.chloeunrau.com/stuff/es-50a.jpg")
cheevo100 = simplegui.load_image("http://www.chloeunrau.com/stuff/es-100a.jpg")

# load sounds
music = simplegui.load_sound("http://www.chloeunrau.com/stuff/music.ogg")
music.set_volume(0.5)
# music source:
# http://www.flashkit.com/
sound_cheevo = simplegui.load_sound("http://www.chloeunrau.com/stuff/achievement.ogg")
sound_cheevo.set_volume(1.0)
sound_score = simplegui.load_sound("http://www.chloeunrau.com/stuff/score.ogg")
sound_score.set_volume(0.3)
sound_fail = simplegui.load_sound("http://www.chloeunrau.com/stuff/fail.ogg")
sound_fail.set_volume(0.5)
sound_score_streak = simplegui.load_sound("http://www.chloeunrau.com/stuff/score-streak.ogg")
sound_score_streak.set_volume(0.5)
sound_reset = simplegui.load_sound("http://www.chloeunrau.com/stuff/reset.ogg")
sound_reset.set_volume(1.0)
sound_game_over = simplegui.load_sound("http://www.chloeunrau.com/stuff/game-over.ogg")
sound_game_over.set_volume(1.0)
开发者ID:unrau,项目名称:Extreme-Stopwatch,代码行数:31,代码来源:Extreme+Stopwatch.py


注:本文中的simplegui.load_sound函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。