• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python pygame.get_error函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: test_set_error

    def test_set_error(self):

        self.assertEqual(pygame.get_error(), "")
        pygame.set_error("hi")
        self.assertEqual(pygame.get_error(), "hi")
        pygame.set_error("")
        self.assertEqual(pygame.get_error(), "")
开发者ID:AceZOfZSpades,项目名称:RankPanda,代码行数:7,代码来源:base_test.py


示例2: test_get_error

    def test_get_error(self):

        # __doc__ (as of 2008-08-02) for pygame.base.get_error:

          # pygame.get_error(): return errorstr
          # get the current error message
          #
          # SDL maintains an internal error message. This message will usually
          # be given to you when pygame.error is raised. You will rarely need to
          # call this function.
          #

        e = pygame.get_error()
        self.assertTrue(e == "" or
                        # This may be returned by SDL_mixer built with
                        # FluidSynth support. Setting environment variable
                        # SDL_SOUNDFONTS to the path of a valid sound font
                        # file removes the error message.
                        e == "No SoundFonts have been requested" or
                        e.startswith("Failed to access the SoundFont"),
                        e)
        pygame.set_error("hi")
        self.assertEqual(pygame.get_error(), "hi")
        pygame.set_error("")
        self.assertEqual(pygame.get_error(), "")
开发者ID:CTPUG,项目名称:pygame_cffi,代码行数:25,代码来源:base_test.py


示例3: test_set_error

    def test_set_error(self):

        # The first error could be all sorts of nonsense or empty.
        e = pygame.get_error()
        pygame.set_error("hi")
        self.assertEqual(pygame.get_error(), "hi")
        pygame.set_error("")
        self.assertEqual(pygame.get_error(), "")
开发者ID:Yarrcad,项目名称:CPSC-386-Pong,代码行数:8,代码来源:base_test.py


示例4: test_set_error

    def test_set_error(self):

        e = pygame.get_error()
        self.assertTrue(e == "" or
                        # This may be returned by SDL_mixer built with
                        # FluidSynth support. Setting environment variable
                        # SDL_SOUNDFONTS to the path of a valid sf2 file
                        # removes the error message.
                        e == "No SoundFonts have been requested",
                        e)
        pygame.set_error("hi")
        self.assertEqual(pygame.get_error(), "hi")
        pygame.set_error("")
        self.assertEqual(pygame.get_error(), "")
开发者ID:Anugrahaa,项目名称:anagrammatic,代码行数:14,代码来源:base_test.py


示例5: load_font

def load_font(f,size=30):
    f = os.path.join('res', f)
    try:
        font = pygame.font.Font(f,size)
    except pygame.error:
        raise SystemExit, 'Could not load font "%s" %s'%(file, pygame.get_error())
    return font
开发者ID:shawnbow,项目名称:dudu123,代码行数:7,代码来源:lib.py


示例6: load_images_pattern

def load_images_pattern(file_pattern, scale = 1):
    file_pattern = os.path.join(Globals.ART_DIR, file_pattern)
    file_list = glob.glob(file_pattern)

    #print file_pattern

    if not file_list:
        print "No file list from pattern"
        return

    image_list = []
    for file in file_list:
        #print file
        try:
            surface = pygame.image.load(file)
        except pygame.error:
            raise SystemExit, 'Could not load image "%s" %s' % (file, pygame.get_error())

        if scale > 1:
            surface = pygame.transform.scale(surface, (surface.get_width()*scale, surface.get_height()*scale))

        img = surface.convert_alpha()
        image_list.append(img)

        if 0 == len(image_list):
            print "Error no image list"

    #print image_list
    return image_list
开发者ID:stdarg,项目名称:invaders,代码行数:29,代码来源:SpriteLib.py


示例7: loadImages

    def loadImages(file_pattern, ObjType):
        file_pattern = os.path.join(Globals.ART_DIR, file_pattern)
        ObjType.file_name_list = glob.glob(file_pattern)

        #print file_pattern
        if not ObjType.file_name_list:
            raise SystemExit, "No file list from pattern '%s'" % file_pattern
            return

        ObjType.image_list = []
        for file in ObjType.file_name_list:
            #print file
            try:
                surface = pygame.image.load(file)
            except pygame.error:
                raise SystemExit, 'Could not load image "%s" %s' % (file, pygame.get_error())

            if ObjType.scale > 1:
                surface = pygame.transform.scale(surface, (surface.get_width()*ObjType.scale, surface.get_height()*ObjType.scale))

            img = surface.convert_alpha()
            ObjType.image_list.append(img)

            ObjType.num_images = len(ObjType.image_list)
            if 0 == ObjType.num_images:
                raise SystemExit, "Error no image list"
开发者ID:stdarg,项目名称:invaders,代码行数:26,代码来源:SpriteLib.py


示例8: loadImage

def loadImage(file, alpha=True):
    file = os.path.join('media', file)
    try:
        surface = pygame.image.load(file)
    except pygame.error:
        raise SystemExit, 'Could not load image "%s" %s'%(file, pygame.get_error())
    return surface.convert_alpha() if alpha else surface
开发者ID:dcbriccetti,项目名称:python-lessons,代码行数:7,代码来源:imageutil.py


示例9: stop

 def stop(self):
   try:
     pygame.mixer.music.stop()
   except pygame.error:
     prettyprint(COLORS.RED, 'Could not stop player! (%s)' % pygame.get_error())
     raise
   self.playing = False
开发者ID:bustardcelly,项目名称:radiopi,代码行数:7,代码来源:broadcast.py


示例10: load_image

def load_image(file):
    file = os.path.join(main_dir, 'data', file)
    try:
        surface = pygame.image.load(file)
    except pygame.error:
        raise SystemExit('Could not load image "%s" %s'%(file, pygame.get_error()))
    return surface
开发者ID:AlexOteiza,项目名称:Bomberman_Party,代码行数:7,代码来源:main.py


示例11: build

    def build(self):
        """Called before the game loop starts."""
        self.setup_cars()
        self.setup_finish_line()
        self.setup_event_handlers()
        self.setup_hud()

        # Load the background and scale to screen size.
        self.background = pygame.image.load('street.png')
        self.background = pygame.transform.scale(self.background,
                                                 self.scr_surf.get_size())

        # Set the delay before a key starts repeating, and the repeat rate.
        pygame.key.set_repeat(250, 25)

        self.hud.flash("Press G to start, R to reset", 2500)

        try:
            self.sounds['race_start'] = pygame.mixer.Sound(file='gunshot.ogg')
            self.sounds['race_end'] = pygame.mixer.Sound(file='winner.ogg')
        except pygame.error:
            print('Error loading sounds: {}'.format(pygame.get_error()))
            exit(1)

        if self.logging_enabled:
            import logging
            logging.info('Game done building.')
开发者ID:ZachMassia,项目名称:pygame-labs,代码行数:27,代码来源:main.py


示例12: loadresources

 def loadresources(self):
     """painting on the surface (once) and create sprites"""
     # make an interesting background 
     draw_examples(self.background) # background artwork
     try:  # ----------- load sprite images -----------
         PygView.images.append(pygame.image.load(os.path.join("data", "babytux.png"))) # index 0
         # load other resources here
     except:
         print("pygame error:", pygame.get_error())
         print("please make sure there is a subfolder 'data' and in it a file 'babytux.png'")
         pygame.quit()
         sys.exit()
     # -------  create (pygame) Sprites Groups and Sprites -------------
     self.allgroup =  pygame.sprite.LayeredUpdates() # for drawing
     self.ballgroup = pygame.sprite.Group()          # for collision detection etc.
     self.hitpointbargroup = pygame.sprite.Group()
     self.bulletgroup = pygame.sprite.Group()
     self.tuxgroup = pygame.sprite.Group()
     self.enemygroup = pygame.sprite.Group()
     # ----- assign Sprite class to sprite Groups ------- 
     Tux.groups = self.allgroup, self.tuxgroup
     Hitpointbar.groups = self.hitpointbargroup
     Ball.groups = self.allgroup, self.ballgroup
     Evildoge.groups = self.enemygroup, self.allgroup
     Bullet.groups = self.allgroup, self.bulletgroup
     self.ball1 = Ball(x=100, y=100) # creating a Ball Sprite
     self.ball2 = Ball(x=200, y=100) # create another Ball Sprite
     self.tux1 = Tux(x=400, y=200, dx=0, dy=0, layer=5, imagenr = 0) # over balls layer
开发者ID:paolo-perfahl,项目名称:mini_rpg,代码行数:28,代码来源:minirpg002.py


示例13: fatalError

	def fatalError(self, msg):
		""" In case of critical errors, this function is called to gracefully
		    shut down the application and print an error message """
		print(self.strings["error"])
		print(msg + ": " + pygame.get_error())
		pygame.quit()
		sys.exit()
开发者ID:rlv-dan,项目名称:BubbleMath,代码行数:7,代码来源:gameflow.py


示例14: play_midi

def play_midi(music_file):
    """
    " stream music with mixer.music module in blocking manner
    " this will stream the sound from disk while playing
    """
    #===== Initiate mixer =====#
    freq = 44100    # audio CD quality
    bitsize = -16   # unsigned 16 bit
    channels = 2    # 1 is mono, 2 is stereo
    buffer = 1024   # number of samples

    pygame.mixer.init(freq, bitsize, channels, buffer)
    pygame.mixer.music.set_volume(1.0)

    clock = pygame.time.Clock()
    try:
        pygame.mixer.music.load(music_file)
        # print "Music file %s loaded!" % music_file
    except pygame.error:
        print "File %s not found! (%s)" % (music_file, pygame.get_error())
        return
    pygame.mixer.music.play()
    while pygame.mixer.music.get_busy():
        # check if playback has finished
        clock.tick(30)
开发者ID:ifbird,项目名称:choir-metronome,代码行数:25,代码来源:midiclass.py


示例15: play_sound

def play_sound(word, volume=0.8):
    """
    stream music with mixer.music module in a blocking manner
    this will stream the sound from disk while playing
    """
    path_file = 'audio/{word}.mp3'.format(word=word)
    # playsound.playsound('audio/{word}.mp3'.format(word=word), True)
    # set up the mixer
    freq = 44100  # audio CD quality
    bitsize = -16  # unsigned 16 bit
    channels = 2  # 1 is mono, 2 is stereo
    buffer = 2048  # number of samples (experiment to get best sound)
    pg.mixer.init(freq, bitsize, channels, buffer)
    # volume value 0.0 to 1.0
    pg.mixer.music.set_volume(volume)
    clock = pg.time.Clock()
    try:
        pg.mixer.music.load(path_file)
        print("Music file {} loaded!".format(path_file))
    except pg.error:
        print("File {} not found! ({})".format(path_file, pg.get_error()))
        return
    pg.mixer.music.play()
    while pg.mixer.music.get_busy():
        # check if playback has finished
        clock.tick(30)
开发者ID:kn7072,项目名称:kn7072,代码行数:26,代码来源:play_audio.py


示例16: get_image_surface

def get_image_surface(sprite_name):
	global _images
	if sprite_name not in SPRITE:
		return None
	if sprite_name in _images:
		return _images[sprite_name]

	cfg = SPRITE[sprite_name]
	fname = os.path.join(IMGDIR, cfg["file"])
	try:
		surface = pygame.image.load(fname).convert_alpha()
	except pygame.error:
		raise SystemExit("Load img error %s %s"%(fname, pygame.get_error()))
	
	_images[sprite_name] = {"surface": surface}

	nx, ny = cfg["matrix"]
	sizex, sizey = cfg["size"]
	index = 0
	for m in xrange(ny):
		y = sizey * m
		for n in xrange(nx):
			x = sizex * n	
			subimg = surface.subsurface(pygame.Rect((x, y), (sizex, sizey)))
			_images[sprite_name][index] = subimg
			index += 1

	return _images[sprite_name]
开发者ID:fanlix,项目名称:fish,代码行数:28,代码来源:res.py


示例17: do_load

    def do_load(self, callback):
        if self.file_name.endswith('.dmd'):
            self.image_surface = (
                mpf.media_controller.display_modules.dmd.load_dmd_file(
                    file_name=self.file_name,
                    palette=dmd_palette,
                    alpha_color=self.alpha_color))
            self.image_surface = self.image_surface[0]
            self.loaded = True

        else:  # image file (.png, .bmp, etc.)
            try:
                self.image_surface = pygame.image.load(self.file_name)
            except pygame.error:
                self.asset_manager.log.error("Pygame Error for file %s. '%s'",
                                             self.file_name, pygame.get_error())
            except:
                raise

            if self.target == 'dmd':
                # This image will be shown on the DMD, so we need to convert its
                # surface to the DMD format

                self.image_surface = (
                    mpf.media_controller.display_modules.dmd.surface_to_dmd(
                    surface=self.image_surface, alpha_color=self.alpha_color))
                # todo add shades here if we ever support values other than 16

        self.loaded = True

        if callback:
            callback()
开发者ID:HarryXS,项目名称:mpf,代码行数:32,代码来源:image.py


示例18: play_music

def play_music(music_file):
    freq = 44100    # audio CD quality=
    bitsize = -16   # unsigned 16 bit
    channels = 2    # 1 is mono, 2 is stereo
    buffer = 1024    # number of samples
    pygame.mixer.init(freq, bitsize, channels, buffer)
    # optional volume 0 to 1.0
    try:
        pygame.mixer.music.set_volume(0.8)
        clock = pygame.time.Clock()
        try:
            pygame.mixer.music.load(music_file)
            print ("\nMusic file %s loaded!" % music_file)
        except pygame.error:
            print ("File %s not found! (%s)" % (music_file, pygame.get_error()) )
            return
        pygame.mixer.music.play()
        print("\nPlaying Music ... ")
        while pygame.mixer.music.get_busy():
            # check if playback has finished
            clock.tick(30)
        print("Done playing!")
    except KeyboardInterrupt:
        # if user hits Ctrl/C then exit
        # (works only in console mode)
        pygame.mixer.music.fadeout(1000)
        pygame.mixer.music.stop()
        raise SystemExit
开发者ID:sookool99,项目名称:Summer2015,代码行数:28,代码来源:playMidiFile.py


示例19: _

 def _(name, transparent=transparent):
     try: surface = pygame.image.load(name)
     except pygame.error:
         raise GamesError( 'Could not load animation frame "%s": %s' % (name, pygame.get_error()) )
     if transparent:
         surface.set_colorkey(surface.get_at((0,0)), RLEACCEL)
     return surface.convert()
开发者ID:CapitainCrunch,项目名称:garbage,代码行数:7,代码来源:games.py


示例20: pg_play_music

def pg_play_music(music_file, volume=0.8):
    """
    stream music with mixer.music module in blocking manner
    this will stream the sound from disk while playing
    """
    # set up the mixer
    freq = 44100     # audio CD quality
    bitsize = -16    # unsigned 16 bit
    channels = 2     # 1 is mono, 2 is stereo
    buffer = 2048    # number of samples (experiment for good sound)
    pg.mixer.init(freq, bitsize, channels, buffer)
    pg.mixer.music.set_volume(volume)
    clock = pg.time.Clock()
    try:
        pg.mixer.music.load(music_file)
        print("Playing file %s" % music_file)
    except pg.error:
        print("File %s not found! (%s)" % \
            (music_file, pg.get_error()))
        return
    pg.mixer.music.play()

    # check if playback has finished
    while pg.mixer.music.get_busy():
        clock.tick(30)
开发者ID:lap089,项目名称:FoscamManager,代码行数:25,代码来源:FoscamManager.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python pygame.get_sdl_byteorder函数代码示例发布时间:2022-05-25
下一篇:
Python util.truncate函数代码示例发布时间:2022-05-25
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap