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

Python resource.image函数代码示例

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

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



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

示例1: __init__

	def __init__(self,x,y):
		self.x = x
		self.y = y
		self.mode = '_'
		self.texes = [resource.image("MC/"+fn+".png") for fn in "idle;back;back1;back2;front;front1;front2;run1;run2;run3".split(';')] \
				+ [resource.image("MC/"+fn+".png",flip_x=True) for fn in "run1;run2;run3".split(";")]
		for _ in  self.texes:
			_.anchor_x = _.width//2
			_.anchor_y = _.height//2
		self.texes = [[self.texes[0]],self.texes[1:4],self.texes[4:7],self.texes[7:10],self.texes[10:]]
		self.texnum = 0.0
开发者ID:ZakkkkAttackkkk,项目名称:hackathon2k15,代码行数:11,代码来源:main.py


示例2: __init__

    def __init__(self, x, y, img_fname, flip_x=False, color=None, opacity=None, batch=None):
        if flip_x:
            super(Item, self).__init__(img=resource.image(name=img_fname, flip_x=True), x=SPRITE_WIDTH*(x+1), y=SPRITE_HEIGHT*y, batch=batch)
        else:
            super(Item, self).__init__(img=resource.image(name=img_fname), x=SPRITE_WIDTH*x, y=SPRITE_HEIGHT*y, batch=batch)

        if color is not None:
            self.color = color

        if opacity is not None:
            self.opacity = opacity

        self._x_units, self._y_units = x, y
开发者ID:varnie,项目名称:snake,代码行数:13,代码来源:Item.py


示例3: grabFrame

	def grabFrame(self):
		"""
		this version of grab frame asumes the timing information is in the clip xml node and extrapolates image number based on time
		"""
		#this version does not allow for "freezing" on last frame and requires looping otherwise returns None -> nothing is drawn
		#todo implement freezing, this should be a either a CLIP property or a GRAPHNODE property that overrides whatever the CLIP property is
		n = self.grabFrameNumber()
		if int(n) <= int(self.xml.getAttribute("frames"))-1:
			#print stupid.splitjoin(self.xml.getAttribute("folder")+self.xml.getAttribute("prefix")+n.zfill(5)+".jpg")
			return resource.image(stupid.splitjoin(self.xml.getAttribute("folder")+self.xml.getAttribute("prefix")+n.zfill(5)+".png"))
		#return the last frame in the clip if we specify freeze = True
		if self.freeze:
			n = str(int(self.xml.getAttribute("frames"))-1)
			return resource.image(stupid.splitjoin(self.xml.getAttribute("folder")+self.xml.getAttribute("prefix")+n.zfill(5)+".png"))
		return None
开发者ID:chippermonky,项目名称:roulette,代码行数:15,代码来源:clip.py


示例4: load

	def load(self):
		self.batch = graphics.Batch()
		self.background = graphics.OrderedGroup(0)
		self.stars = Stars(Size(2000, 2000), self.batch, self.background)
		centre = Vector(self.size.width/2, self.size.height/2)
		image = centre_image(resource.image("win.png"))
		self.logo = sprite.Sprite(image, centre.x, centre.y)
开发者ID:Lattyware,项目名称:asteroidbelt,代码行数:7,代码来源:scenes.py


示例5: __init__

    def __init__(self, client, points=9, eye=1, wait=1, randomize=1, auto=0, speed=1, level=3):
        super(CalibrationLayer, self).__init__(0, 0, 255, 255)
        self.client = client
        self.points = points
        self.eye = eye
        self.wait = wait
        self.randomize = randomize
        self.auto = auto
        self.speed = speed
        self.level = level
        self.on_success = None
        self.on_failure = None

        self.window = director.window.get_size()
        self.screen = director.get_window_size()
        self.center_x = self.screen[0] / 2
        self.center_y = self.screen[1] / 2
        self.win_scale = (self.screen[0] / self.window[0], self.screen[1] / self.window[1])

        self.font = font.load("Cut Outs for 3D FX", 32)
        self.circle_img = self.font.get_glyphs("E")[0].get_texture(True)
        self.circle_img.anchor_x = "center"
        self.circle_img.anchor_y = "center"
        self.pnt_img = self.font.get_glyphs("Y")[0].get_texture(True)
        self.pnt_img.anchor_x = "center"
        self.pnt_img.anchor_y = "center"

        self.circle = Sprite(self.circle_img, color=(255, 255, 0), scale=1, opacity=0)
        self.spinner = Sprite(
            resource.image("spinner.png"), position=(self.screen[0] / 2, self.screen[1] / 2), color=(255, 255, 255)
        )
开发者ID:CogWorks,项目名称:WhackAMole,代码行数:31,代码来源:calibrator.py


示例6: __init__

    def __init__(self, *args, image=image('assets/blue_box.png'), **kwargs):
        super().__init__(image, **kwargs)
        self.__dict__.update(kwargs)
        self.aim_cursor = AimCursor(mouse_angle=0.00, player_x=self.cx, player_y=self.cy)

        # Setup Player Movement
        self.max_velocity = 10
        self.vel_x = 0
        self.vel_y = 0
        self.acceleration = 2
        self.quad_coefficient = 0.15
        self.animation_time = 5
        self.is_jumping = False
        self.is_falling = False
        self.quadrant_setup = False

        # Setup Mouse
        self.mouse_angle = 0
        self.mouse_dx = 0
        self.mouse_dy = 0
        self.mouse_velocity = 4

        # Setup Physics
        self.gravity = 5
        self.mass = 5
        self.terminal_velocity = self.max_velocity * self.gravity
        self.max_jumps = 2
        self.jumps = 0


        self.keys_pressed = {}
开发者ID:jaitaiwan,项目名称:idabb,代码行数:31,代码来源:player.py


示例7: get_texture

 def get_texture(fname):
     cache = ImageCache.cache
     tex = cache.get(fname, None)
     if not tex:
         tex = resource.image(fname).texture
         ImageCache.cache[fname] = tex
     return tex
开发者ID:Incantus,项目名称:incantus,代码行数:7,代码来源:resources.py


示例8: _load

 def _load(filename, key, anchor=False):
     cache = ImageCache.cache
     value = resource.image(filename)
     if anchor:
         value.anchor_x = value.width / 2
         value.anchor_y = value.height / 2
     cache[key] = value
开发者ID:Incantus,项目名称:incantus,代码行数:7,代码来源:resources.py


示例9: _load_multi

 def _load_multi(filename, labels, rows, columns, anchor=False):
     cache = ImageCache.cache
     multiimage = image.ImageGrid(resource.image(filename), rows, columns)
     for key, texture in zip(labels, multiimage):
         if anchor:
             texture.anchor_x = texture.width / 2
             texture.anchor_y = texture.height / 2
         cache[key] = texture
开发者ID:Incantus,项目名称:incantus,代码行数:8,代码来源:resources.py


示例10: load_sprite_animation

def load_sprite_animation(name, action, frames=8, duration=0.1):
    " Creates an animation from files in the assets folder "
    images = [resource.image("assets/%s/%s%d.png" % (name, action, i))
                for i in range(1, frames + 1)]
    for image in images:
        image.anchor_x = image.width / 2
    frames = [AnimationFrame(i, duration) for i in images]
    return Animation(frames)
开发者ID:johnmendel,项目名称:python-tactics,代码行数:8,代码来源:util.py


示例11: load

    def load(self):
        resource.path = ["data"]
        resource.reindex()
        numbers = resource.image("numbers.png")

        self.numbers = {}
        width = numbers.width / 10
        for n in xrange(0, 10):
            self.numbers[n] = numbers.get_region(n * width, 0, width, numbers.height)
开发者ID:tartley,项目名称:pyong,代码行数:9,代码来源:bitmaps.py


示例12: _load_images

    def _load_images(self, tiles):
        self.tile_images = []
        for path, solid in tiles:
            image = resource.image(path)
            image.solid = solid
            self.tile_images.append(image)

        self.tile_width = max(image.width for image in self.tile_images)
        self.tile_height = max(image.height for image in self.tile_images)
开发者ID:ceronman,项目名称:prisionescape,代码行数:9,代码来源:tilemap.py


示例13: __init__

    def __init__(self):
        self.x = 850
        self.y = 550
        self.img = resource.image('sun.png')
        self.img.anchor_x = self.img.width / 2
        self.img.anchor_y = self.img.height / 2
        self.rotation = 0

        pyglet.clock.schedule(self.update)
开发者ID:pdevine,项目名称:happytown-python,代码行数:9,代码来源:title.py


示例14: populated

	def populated(self, populated):
		if not populated == self._populated:
			self._populated = populated
			if populated:
				name = self.type
			else:
				name = "raw_"+self.type
			self.sprite.image = centre_image(resource.image(name+".png"))
			if self.type == "home": #HACK
				self.sprite.visible = True
开发者ID:Lattyware,项目名称:asteroidbelt,代码行数:10,代码来源:entities.py


示例15: __init__

    def __init__(self, path):
        """
        Takes the :param:`path` , verifies its dimensions and sets it as texture.

        :param path: The path of the image
        """
        self.image_name = path.split('/')[-1]
        self.image = resource.image(self.image_name).texture
        self.verify_dimensions()
        glGenerateMipmap(self.image.target)
开发者ID:sgeyer-tgm,项目名称:SolarSystem,代码行数:10,代码来源:texture.py


示例16: selectLevel

 def selectLevel(self, name):
     """
     Maybe add more levels?
     """
     self.bgimage = resource.image('images/'+name+'.jpg')
     map = self.buildMap(name)
     for building in map:
         b = rabbyt.Sprite(None, building[0])
         b.xy = building[1]
         self.map_objects.append(b)
开发者ID:phantomxc,项目名称:KrackedForc,代码行数:10,代码来源:world.py


示例17: __init__

    def __init__(self, game, circle=None, margin=20):
        self.game = game
        self.planets = {}
        self.fleets = {}
        self.margin = margin
        self.circle = circle

        # images
        self.bk_img = resource.image(IMAGES['background'])
        self.bk_sprite = sprite.Sprite(self.bk_img)
开发者ID:Dan-Newman,项目名称:AI4Games,代码行数:10,代码来源:main.py


示例18: __init__

 def __init__(self):
     self.screen = director.get_window_size()
     super(TaskBackground, self).__init__()
     img = resource.image('background.jpg')
     if self.screen[0] > 1600:
         scale = max(self.screen[0]/1600,self.screen[1]/1000)
     elif self.screen[0] < 1600:
         scale = min(self.screen[0]/1600,self.screen[1]/1000)
     s = Sprite(img,position=(self.screen[0]/2,self.screen[1]/2),scale=scale)
     self.add(s)
     self.add(ColorLayer(128,128,128,128),z=1)
开发者ID:CogWorks,项目名称:pySnake,代码行数:11,代码来源:main.py


示例19: load_rltile

 def load_rltile(self, name, path):
     badimg = image(path)
     badimgd = badimg.get_image_data()
     bad_rgba = badimgd.get_data('RGBA', badimgd.pitch)
     good_data = bad_rgba.replace('\xffGll', '\x00Gll')
     good_data = good_data.replace('\xff.', '\x00.')
     badimgd.set_data('RGBA', badimgd.pitch, good_data)
     rtex = badimgd.get_texture()
     rtex.name = name
     self.imgdict[name] = rtex
     return rtex
开发者ID:LogicalDash,项目名称:PyLand,代码行数:11,代码来源:database.py


示例20: grabFrameOLD

	def grabFrameOLD(self):
		"""
		this version of grabframe assumes that the clip xml node has all its images listed with their respective times.
		Use this version if you want to have a non constant speed animation.
		"""
		#TODO you should really make at least a local dict of image names to map becaus ethis loads the same image multiple times...
		#print self.xml,"frame","number",self.grabFrameNumber()
		framexml = utils.getChildWithAttribute(self.xml,"frame","number",self.grabFrameNumber())
		if framexml:
			return resource.image(stupid.splitjoin(framexml.getAttribute("folder")+framexml.getAttribute("filename")))
		else: return None
开发者ID:chippermonky,项目名称:roulette,代码行数:11,代码来源:clip.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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