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

Python image.load函数代码示例

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

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



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

示例1: _initSpellImage

    def _initSpellImage(self):

        self.fireball = image.load("Res/fireball.png")
        self.teleport = image.load("Res/teleport.png")
        self.frostNova = image.load("Res/frostnova.png")
        self.fireNova = image.load("Res/firenova.jpg")
        self.shield = image.load("Res/shield.png")
开发者ID:salian2,项目名称:Semestralka-UNIX,代码行数:7,代码来源:Images.py


示例2: load_frames

    def load_frames(self, path, frames, convert_alpha=False):
        """
        Load a sequence of image named 1.ext...*frames*.ext from *path*
        *ext* must be consistent

        :param path: Path in list format pointing to a directory
        :param frames: Number of frames to load
        :param convert_alpha: whether surfaces are converted with convert_alpha()
        :return: a list of surfaces
        """
        dir_path = self.get_path(path)
        extension = ""
        for name in listdir(dir_path):
            file = join(dir_path, name)
            if isfile(file):
                striped, file_ext = splitext(name)
                if striped == "1":
                    extension = file_ext
                    break
        surfs = []
        for c in range(1, frames + 1):
            file = join(dir_path, str(c) + extension)
            if convert_alpha:
                surfs.append(load(file).convert_alpha())
                continue
            surfs.append(load(file).convert())
        return surfs
开发者ID:XrXr,项目名称:RapidPygame,代码行数:27,代码来源:image.py


示例3: load_tile

def load_tile(element, side=1):  # side = 1: bottom, side = 0: top
    """
    :type side: object
    :param element:
    :param side:
    :return:
    """
    if element == T_VOID:
        return False
    else:
        if side == 1:
            # tile = Image.load(r"../graphics/tile"+element+".png")
            if element == T_ACQUA:
                tile = py_image.load(r"../graphics/tile" + element + ".png")
                return tile
            if element.startswith(T_SABBIA):
                tile = py_image.load(r"../graphics/tile0_base.png")
            else:
                tile = py_image.load(r"../graphics/tile" + element + ".png")
                tile = tile.subsurface(0, (BLOCCOY / 2), BLOCCOX, BLOCCOY / 2)  # left top width height
        # tile = tile.subsurface(0,side*(BLOCCOY/2),BLOCCOX,BLOCCOY/2)#left top width height
        else:
            tile = py_image.load(r"../graphics/tile" + element + ".png")
            if T_ACQUA == element:
                return False
            tile = tile.subsurface(0, 0, BLOCCOX, BLOCCOY / 2)  # left top width height
            if element.startswith(T_SABBIA):
                tile = py_image.load(r"../graphics/tile" + T_SABBIA + "_top_" + element.split('_')[-1] + ".png")
    return tile
开发者ID:DanielSantoyo,项目名称:videogame,代码行数:29,代码来源:genesi.py


示例4: __init__

 def __init__(self, level, size, player):
     State.State.__init__(self)
     G.play_amb()
     # loads image if not already
     if not CutScene.IMAGE:
         CutScene.IMAGE = PI.load("sprites/images/down.jpg").convert()
     self.image = CutScene.IMAGE
     # lets us know when to fade in
     self.fade_in = True
     # the x variable of the black shade surface
     self.dx = G.Globals.WIDTH
     # the x, y top left positions
     self.x = 0
     self.y = 0
     self.time = 0
     # surface that shades over image to create sliding effect
     self.slide_surface = PG.Surface((self.dx, G.Globals.HEIGHT +
                                      G.Globals.HUD_HEIGHT))
     self.level = level
     self.size = size
     self.player = player   
     if level == 5:
         images = []
         img_1 = PI.load("sprites/images/enter.jpg").convert()
         img_2 = PI.load("sprites/images/catfight.jpg").convert()
         images.append(img_1)
         images.append(img_2)
         G.Globals.STATE = StoryBoard.StoryBoard("story_texts/boss_text.txt",
                                               images)     
开发者ID:BitBallers,项目名称:GammaRayKitten,代码行数:29,代码来源:CutScene.py


示例5: __init__

    def __init__(self, surf_width, surf_height, loc_x, loc_y, direction, volume):
        self.time = 0.0
        self.volume = volume

        #set speed
        self.vx = ROCKET_VELOCITY

        self.surf_width = surf_width
        self.surf_height = surf_height

        #load image
        PS.Sprite.__init__(self)
        if not Virusbubble.IMAGE:
            self.IMAGE = PI.load("enemy_animation/virus/projectile.png").convert_alpha()
            self.IMAGE_NEG = PI.load("enemy_animation/virus/projectile_neg.png").convert_alpha()
        self.image = self.IMAGE
        self.rect = self.image.get_rect()

        #position rocket
        self.rect.centery = loc_y
        self.rect.centerx = loc_x

        self.sound = PM.Sound("Sounds/effects/virus_attack.ogg")
        self.sound.set_volume(self.volume)

        self.KILL = False
        self.moving_right = direction
开发者ID:rogerzxu,项目名称:OrganDonor,代码行数:27,代码来源:rocket.py


示例6: loadImage

 def loadImage(self,  imageName,  alpha = True):
     imagePath = "../resrc/img/RPG/" + imageName + ".png"
     if alpha:
         img = load(imagePath).convert_alpha()
     else:
         img = load(imagePath).convert()
     return img
开发者ID:rlegendi,项目名称:Taltos,代码行数:7,代码来源:ImageHandler.py


示例7: __init__

	def __init__(self, direction, resourcePath):
		self.direction = direction
		if (self.direction == "up"):
			self.image = image.load(resourcePath + "img/uparrow.png")
		elif (self.direction == "down"):
			self.image = image.load(resourcePath + "img/downarrow.png")
		self.rect = Rect((0, 0), self.image.get_size())
开发者ID:ZakFarmer,项目名称:OregonTrail,代码行数:7,代码来源:scrollButton.py


示例8: __init__

    def __init__(self):
        super(Level0, self).__init__()

        self.activeSprites = sprite.RenderClear()
        self.drawnSprites = []
        self.npc = GameObject(image.load('User.png'), 100,50)
        self.activeSprites.add(self.npc)
        
        self.block1 = GameObject(image.load('platform.png'), 100, 400)
        self.activeSprites.add(self.block1);

        self.mousex = 0
        self.mousey = 0

	#The highest height our npc
	#can climb. If a the dY with a
	#point is higher than this, the
	#npc will just fall to his death
	self.MAX_HILL_HEIGHT = 3

	self.toDrawRectTopLeft = (0,0)
	self.toDrawRectBottomRight = (0,0)

        self.drawing = False

        self.pts = []

        print "Level 0 initialized."
开发者ID:Berulacks,项目名称:ethosgame,代码行数:28,代码来源:level0.py


示例9: __init__

 def __init__(self,imagefile,soundfile,trgtimg,trgtsnd):
     self.image = scale(image.load(imagefile), SIZE).convert()
     self.fill = scale(image.load(BASE),SIZE).convert()
     self.sound = mixer.Sound(soundfile)
     self.trgtimg = trgtimg
     self.trgtsnd = trgtsnd
     self.result = [not(self.trgtimg),not(self.trgtsnd)]
开发者ID:sfavors3,项目名称:MindMixer,代码行数:7,代码来源:mindmixer.py


示例10: sup_load_images

    def sup_load_images(self):
        SuperSlime.IMAGES = []
        sheet = PI.load(
            "sprites/images/slime_sprite_sheet.png").convert_alpha()
        c_surface = PG.Surface((sheet.get_width(), sheet.get_height())).convert()
        c_surface.fill((150, 0, 150))
        sheet.blit(c_surface, (0, 0), None, PG.BLEND_ADD)
        key = sheet.get_at((0, 0))
        for y in range(4):
            for x in range(5):
                surface = PG.Surface((30, 20)).convert()
                surface.set_colorkey(key)
                surface.blit(sheet, (0, 0), (x * 30, y * 20, 30, 20))
                SuperSlime.IMAGES.append(surface)

        SuperSlime.DEATH_IMAGES = []
        sheet = PI.load(
            "sprites/images/slime_sprite_sheet_death.png").convert_alpha()
        c_surface = PG.Surface((sheet.get_width(), sheet.get_height())).convert()
        c_surface.fill((150, 0, 150))
        sheet.blit(c_surface, (0, 0), None, PG.BLEND_ADD)

        key = sheet.get_at((0, 0))
        for y in range(2):
            for x in range(4):
                surface = PG.Surface((30, 20)).convert()
                surface.set_colorkey(key)
                surface.blit(sheet, (0, 0), (x * 30, y * 20, 30, 20))
                SuperSlime.DEATH_IMAGES.append(surface)
开发者ID:BitBallers,项目名称:GammaRayKitten,代码行数:29,代码来源:SuperSlime.py


示例11: loadTextures

    def loadTextures(self):
        self.main_wall_texture = image.load(os.path.join('data', 'walls.png')).convert()
        main_texture_size = self.main_wall_texture.get_size()
        self.textures_count = round(main_texture_size[1]/self.texture_size)
        self.texture_types_count = round(main_texture_size[0]/self.texture_size)
        self.wall_textures = []
        for i in range(self.textures_count):
            texture_types = []
            for t in range(self.texture_types_count-1):
                texture_type = []
                x = t * self.texture_size
                y = i * self.texture_size
                for strip in range(self.texture_size):
                    texture_type.append(
                        self.main_wall_texture.subsurface((x, y, 1, self.texture_size)).convert()
                    )
                    x = x + 1
                texture_types.append(texture_type)
            self.wall_textures.append(texture_types)
        pass

        self.main_sprite_texture = image.load(os.path.join('data', 'sprites.png')).convert()
        self.sprites_count = self.main_sprite_texture.get_size()[0]//self.texture_size
        self.sprites = []
        for i in range(self.sprites_count):
            sprite = []
            x = i * self.texture_size
            y = 0
            for strip in range(self.texture_size):
                sprite.append(
                    self.main_sprite_texture.subsurface((x, y, 1, self.texture_size)).convert()
                )
                x = x + 1
            self.sprites.append(sprite)
        pass
开发者ID:grisevg,项目名称:RayCastPy,代码行数:35,代码来源:display.py


示例12: load_images

 def load_images(self):
     self.health = SHIPHEALTH
     self.IMAGES = []
     self.NEG_IMAGES = []
     walkr = "enemy_animation/spaceship/1.png"
     walkl = "enemy_animation/spaceship/-1.png"
     self.IMAGES.append(PI.load(walkr).convert_alpha())
     self.NEG_IMAGES.append(PI.load(walkl).convert_alpha())
开发者ID:rogerzxu,项目名称:OrganDonor,代码行数:8,代码来源:enemy.py


示例13: setPic

 def setPic(self):
     if (self.color == 'black'):
         self.image = image.load("C:\Users\Colleen\Pictures\usedInSomething\BlackRook.png").convert_alpha()
         # convert alpha preserves per pixel transparency
     elif (self.color == 'white'):
         self.image = image.load("C:\Users\Colleen\Pictures\usedInSomething\whiteRook.png").convert_alpha()
     else:
         print "Color issue with Rook"
开发者ID:crockct,项目名称:Colleens_Chess,代码行数:8,代码来源:ChessPieces.py


示例14: _initNpcImage

    def _initNpcImage(self):

        leviathan = image.load("Res/leviathan.png")
        bahamut = image.load("Res/bahamut.png")
        ifrit = image.load("Res/ifrit.png")
        self.npc.append(leviathan)
        self.npc.append(bahamut)
        self.npc.append(ifrit)
开发者ID:salian2,项目名称:Semestralka-UNIX,代码行数:8,代码来源:Images.py


示例15: __init__

 def __init__(self, nr_of_rectangles):
     self.image_e = load("e.png")
     self.image_x = load("x.png")
     self.image_o = load("o.png") #TODO add the o image
     dimensions = Rectangle(0, 0, self.image_x.get_width(),
                                  self.image_x.get_height())
     self.players_turn = 0
     Board.__init__(self, nr_of_rectangles, dimensions)
开发者ID:LajaviKrelac,项目名称:GGS,代码行数:8,代码来源:tictactoeboard.py


示例16: load_images

 def load_images(self):
     sheetR = PI.load("FPGraphics/Food/IceCreamWalkRight.png").convert_alpha()
     sheetL = PI.load("FPGraphics/Food/IceCreamWalkLeft.png").convert_alpha()
     sheetF = PI.load("FPGraphics/Food/IceCreamWalkFront.png").convert_alpha()
     sheetB = PI.load("FPGraphics/Food/IceCreamWalkBack.png").convert_alpha()
     self.IMAGES_RIGHT = self.load_images_helper(self.IMAGES_RIGHT, sheetR)
     self.IMAGES_LEFT = self.load_images_helper(self.IMAGES_LEFT, sheetL)
     self.IMAGES_FRONT = self.load_images_helper(self.IMAGES_FRONT, sheetF)
     self.IMAGES_BACK = self.load_images_helper(self.IMAGES_BACK, sheetB)
开发者ID:fryingpan,项目名称:Assignment2,代码行数:9,代码来源:IceCream.py


示例17: draw_walls

    def draw_walls(self, screen):
        wall_pic = image.load("assets/brick.png")
        unbreakable_wall_pic = image.load("assets/wall.png")

        for wall in self.wall_rects:
            if wall.wall.breakable:
                screen.blit(wall_pic, (wall.x, wall.y))
            else:
                screen.blit(unbreakable_wall_pic, (wall.x, wall.y))
开发者ID:stormbreakerbg,项目名称:battle_city_game,代码行数:9,代码来源:world_wrapper.py


示例18: load_images

 def load_images(self, t):
     ##load hot pad images
     if t == 0:
         sheet = PI.load("FPGraphics/tiles/lv2Tiles/heatPadAnim.png").convert_alpha()
     ##load cold pad images
     if t == 1:
         sheet = PI.load("FPGraphics/tiles/lv3Tiles/coldPadAnim.png").convert_alpha()
     # else:
     self.IMAGES = self.load_images_helper(self.IMAGES, sheet)
开发者ID:fryingpan,项目名称:Assignment2,代码行数:9,代码来源:pad.py


示例19: __init__

 def __init__(self,sx=0, sy=0):
     global attacktimeout, attack
     self.img = image.load(os.path.join("assets", "stone.png")).convert_alpha()
     self.keafriend = image.load(os.path.join("assets", "keacarrystone.png")).convert_alpha()
     self.x = sx
     self.y = sy
     self.grabed = False
     self.initial = True
     self.deliverymode = False
开发者ID:green0range,项目名称:Uninterrupted-Kea-Experience,代码行数:9,代码来源:tiger.py


示例20: load_images

def load_images():
    images_loaded = {}
    for png_file in [f[:-4] for f in listdir('../art') if f[-4:] == '.png']:
        images_loaded[png_file] = image.load(
                '../art/{}.png'.format(png_file))
    for png_file in [f[:-4] for f in listdir('../art/biomes') if f[-4:] == '.png']:
        images_loaded[png_file] = image.load(
                '../art/biomes/{}.png'.format(png_file)).convert()
    return images_loaded
开发者ID:Danquebec,项目名称:Societes,代码行数:9,代码来源:loader.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python mask.from_surface函数代码示例发布时间:2022-05-25
下一篇:
Python font.Font类代码示例发布时间: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