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


Python Surface.__init__方法代码示例

本文整理汇总了Python中pygame.Surface.__init__方法的典型用法代码示例。如果您正苦于以下问题:Python Surface.__init__方法的具体用法?Python Surface.__init__怎么用?Python Surface.__init__使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pygame.Surface的用法示例。


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

示例1: __init__

# 需要导入模块: from pygame import Surface [as 别名]
# 或者: from pygame.Surface import __init__ [as 别名]
 def __init__(self):
     scrsize = self.w, self.h = display.get_surface().get_size()
     Surface.__init__(self, scrsize)
     self.foo = 0
     self.l0 = []
     self.l1 = []
     self.l2 = []
开发者ID:strin,项目名称:curriculum-deep-RL,代码行数:9,代码来源:starsfield.py

示例2: __init__

# 需要导入模块: from pygame import Surface [as 别名]
# 或者: from pygame.Surface import __init__ [as 别名]
    def __init__(self, line, surf_w, justify):
        # renders a line (list of tokens)
        # accepts a line (list of tokens), width of line, and justification
        # returns Surface object with the tokens justified upon it given the
        #   justify argument
        self.line = line
        self.links = defaultdict(list)

        links = self.links
        scale_token = _scale_token

        # get the line width, line height, whitespace used in the line, and
        # freespace remaining in the line
        line_w = sum(token.get_width() for token in line)
        line_h = max(token.get_height() for token in line)
        total_whitespace = sum(token.get_width() for token in line
                               if token.iswhitespace)
        freespace = surf_w - line_w # the freespace available in the surface

        # initialize surface
        Surface.__init__(self, (surf_w, line_h))
        self.set_colorkey(BLACK)

        # set x
        if justify == 'right': x = freespace
        elif justify == 'center': x = freespace / 2
        else: x = 0

        # if justified: modify whitespace widths
        if justify == 'justified':
            # the amount to stretch whitespace
            stretch = 1.0 + (freespace / total_whitespace)

            sub_w = 0
            for i, token in enumerate(line):
                if token.iswhitespace:
                    # replace token with a scaled token
                    token_w = token.get_width() * stretch
                    scale_w = int(token_w)
                    sub_w += token_w % scale_w
                    while sub_w > 1:
                        sub_w -= 1
                        scale_w += 1
                    line[i] = scale_token(token, (scale_w, token.get_height()))

        for token in line:
            w, h = token.get_size()
            y = (line_h - h) # token y
            self.blit(token, (x, y))

            for link in token.links:
                for rect in token.links[link]:
                    # move rect to token's position in line and append to links
                    links[link].append(rect.move(x, y))

            x += w # update x with object width
开发者ID:Teognis,项目名称:GruEngine,代码行数:58,代码来源:_glyph.py

示例3: __init__

# 需要导入模块: from pygame import Surface [as 别名]
# 或者: from pygame.Surface import __init__ [as 别名]
 def __init__(self, position, size, passenger, resource_path):
     Surface.__init__(self, size)
     self.position = position
     self.size = size
     self.passenger = passenger
     self.text_font = font.Font(None, 15)
     self.passenger_surface = Surface(self.size).convert()
     self.rect = Rect(self.position, self.size)
     self.option_image = transform.scale(image.load(resource_path+"Images/option_icon.png"), (20, 20))
     self.option_rect = self.option_image.get_rect()
开发者ID:brandonsturgeon,项目名称:Oregon_Trail,代码行数:12,代码来源:passenger_tab.py

示例4: __init__

# 需要导入模块: from pygame import Surface [as 别名]
# 或者: from pygame.Surface import __init__ [as 别名]
    def __init__(self, disp_res, fb_res, flags=HWSURFACE|DOUBLEBUF|RESIZABLE,
                 fps=60, scale_type='pixelperfect', scale_smooth=False, bgcolor=(0,0,0)):
        screen = display.set_mode(disp_res, flags)
        Surface.__init__(self, fb_res, flags)

        self._scale_type = scale_type
        self._scale_function = transform.smoothscale if scale_smooth else transform.scale
        self.bgcolor = bgcolor
        self.compute_target_subsurf()
 
        self._update_rects = []

        self._clock = time.Clock()
        self._fps = fps
        self._lag = 0
        self._tdelta = 0

        if FrameBuffer.instance is None:
            FrameBuffer.instance = self
开发者ID:ViperX420,项目名称:padpyght,代码行数:21,代码来源:frame_buffer.py

示例5: __init__

# 需要导入模块: from pygame import Surface [as 别名]
# 或者: from pygame.Surface import __init__ [as 别名]
	def __init__ (self, size):
		Surface.__init__(self, size)
		self.fill((50,50,50))
开发者ID:borntyping-sandbox,项目名称:misc,代码行数:5,代码来源:main.py

示例6: __init__

# 需要导入模块: from pygame import Surface [as 别名]
# 或者: from pygame.Surface import __init__ [as 别名]
 def __init__ (self, width, height, alpha=255):
     Surface.__init__ (self, (width, height), SRCALPHA, 32)
     self._alpha = 255
     self._step = -1
     self.set_alpha (alpha)
开发者ID:BGCX067,项目名称:eyestabs-svn-to-git,代码行数:7,代码来源:Complex.py

示例7: __init__

# 需要导入模块: from pygame import Surface [as 别名]
# 或者: from pygame.Surface import __init__ [as 别名]
 def __init__(self, dim, relXOff, relYOff):
     Surface.__init__(self, dim, SRCALPHA)
     self.xOff = glob.Screen.WIDTH * 0.5 + relXOff
     self.yOff = glob.Screen.HEIGHT * 0.5 + relYOff
开发者ID:coleary9,项目名称:RockBrawl,代码行数:6,代码来源:frameLoader.py


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