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


Python pygame.BLEND_RGBA_MULT属性代码示例

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


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

示例1: update

# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import BLEND_RGBA_MULT [as 别名]
def update(self):
        self.get_keys()
        self.rot = (self.rot + self.rot_speed * self.game.dt) % 360
        self.image = pg.transform.rotate(self.game.player_img, self.rot)
        if self.damaged:
            try:
                self.image.fill((255, 255, 255, next(self.damage_alpha)), special_flags=pg.BLEND_RGBA_MULT)
            except:
                self.damaged = False
        self.rect = self.image.get_rect()
        self.rect.center = self.pos
        self.pos += self.vel * self.game.dt
        self.hit_rect.centerx = self.pos.x
        collide_with_walls(self, self.game.walls, 'x')
        self.hit_rect.centery = self.pos.y
        collide_with_walls(self, self.game.walls, 'y')
        self.rect.center = self.hit_rect.center 
开发者ID:kidscancode,项目名称:pygame_tutorials,代码行数:19,代码来源:sprites.py

示例2: damage_animation

# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import BLEND_RGBA_MULT [as 别名]
def damage_animation(self):
        """
        Put a red overlay over sprite to indicate damage.
        """
        if self.damaged:
            self.image = copy.copy(self.spritesheet_dict['facing left 2'])
            self.image = pg.transform.scale2x(self.image).convert_alpha()
            damage_image = copy.copy(self.image).convert_alpha()
            damage_image.fill((255, 0, 0, self.damage_alpha), special_flags=pg.BLEND_RGBA_MULT)
            self.image.blit(damage_image, (0, 0))
            if self.fade_in:
                self.damage_alpha += 25
                if self.damage_alpha >= 255:
                    self.fade_in = False
                    self.damage_alpha = 255
            elif not self.fade_in:
                self.damage_alpha -= 25
                if self.damage_alpha <= 0:
                    self.damage_alpha = 0
                    self.damaged = False
                    self.fade_in = True
                    self.image = self.spritesheet_dict['facing left 2']
                    self.image = pg.transform.scale2x(self.image) 
开发者ID:justinmeister,项目名称:The-Stolen-Crown-RPG,代码行数:25,代码来源:person.py

示例3: healing_animation

# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import BLEND_RGBA_MULT [as 别名]
def healing_animation(self):
        """
        Put a green overlay over sprite to indicate healing.
        """
        if self.healing:
            self.image = copy.copy(self.spritesheet_dict['facing left 2'])
            self.image = pg.transform.scale2x(self.image).convert_alpha()
            healing_image = copy.copy(self.image).convert_alpha()
            healing_image.fill((0, 255, 0, self.healing_alpha), special_flags=pg.BLEND_RGBA_MULT)
            self.image.blit(healing_image, (0, 0))
            if self.fade_in:
                self.healing_alpha += 25
                if self.healing_alpha >= 255:
                    self.fade_in = False
                    self.healing_alpha = 255
            elif not self.fade_in:
                self.healing_alpha -= 25
                if self.healing_alpha <= 0:
                    self.healing_alpha = 0
                    self.healing = False
                    self.fade_in = True
                    self.image = self.spritesheet_dict['facing left 2']
                    self.image = pg.transform.scale2x(self.image) 
开发者ID:justinmeister,项目名称:The-Stolen-Crown-RPG,代码行数:25,代码来源:person.py

示例4: test_blend_rgba

# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import BLEND_RGBA_MULT [as 别名]
def test_blend_rgba(self):
        bitsizes = [16, 32]
        blends = ['BLEND_RGBA_ADD',
                  'BLEND_RGBA_SUB',
                  'BLEND_RGBA_MULT',
                  'BLEND_RGBA_MIN',
                  'BLEND_RGBA_MAX']
        for bitsize in bitsizes:
            surf = self._make_surface(bitsize, srcalpha=True)
            comp = self._make_surface(bitsize, srcalpha=True)
            for blend in blends:
                self._fill_surface(surf)
                self._fill_surface(comp)
                comp.blit(surf, (3, 0),
                          special_flags=getattr(pygame, blend))
                surf.blit(surf, (3, 0),
                          special_flags=getattr(pygame, blend))
                self._assert_same(surf, comp) 
开发者ID:wistbean,项目名称:fxxkpython,代码行数:20,代码来源:surface_test.py

示例5: blit_mask

# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import BLEND_RGBA_MULT [as 别名]
def blit_mask(source, dest, destpos, mask, maskrect):
        """
        Blit an source image to the dest surface, at destpos, with a mask, using
        only the maskrect part of the mask.
        """
        tmp = source.copy()
        tmp.blit(mask, maskrect.topleft, maskrect, special_flags=pygame.BLEND_RGBA_MULT)
        dest.blit(tmp, destpos, dest.get_rect().clip(maskrect)) 
开发者ID:songyanho,项目名称:Reinforcement-Learning-for-Self-Driving-Cars,代码行数:10,代码来源:road.py

示例6: draw_plot_pause

# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import BLEND_RGBA_MULT [as 别名]
def draw_plot_pause():
        pause_font = pygame.font.SysFont("Arial", 25)
        yellow = (255, 255, 179)
        txt_surf = pause_font.render('pause', False, (80., 80., 80.))
        alpha_img = pygame.Surface(txt_surf.get_size(), pygame.SRCALPHA)
        alpha_img.fill(yellow + (72,))
        # txt_surf.blit(alpha_img, (0, 0), special_flags=pygame.BLEND_RGBA_MULT)

        pause_surface = pygame.Surface((200, 70), pygame.SRCALPHA, 32).convert_alpha()
        pause_surface.fill(yellow + (128,))
        pause_surface.blit(txt_surf, (64, 18))

        return pause_surface 
开发者ID:shidi1985,项目名称:L2RPN,代码行数:15,代码来源:renderer.py

示例7: draw_plot_game_over

# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import BLEND_RGBA_MULT [as 别名]
def draw_plot_game_over():
        game_over_font = pygame.font.SysFont("Arial", 25)
        red = (255, 26, 26)
        txt_surf = game_over_font.render('game over', False, (255, 255, 255))
        alpha_img = pygame.Surface(txt_surf.get_size(), pygame.SRCALPHA)
        alpha_img.fill(red + (128,))
        # txt_surf.blit(alpha_img, (0, 0), special_flags=pygame.BLEND_RGBA_MULT)

        game_over_surface = pygame.Surface((200, 70), pygame.SRCALPHA, 32).convert_alpha()
        game_over_surface.fill(red + (128,))
        game_over_surface.blit(txt_surf, (38, 18))

        return game_over_surface 
开发者ID:shidi1985,项目名称:L2RPN,代码行数:15,代码来源:renderer.py

示例8: render

# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import BLEND_RGBA_MULT [as 别名]
def render(self, screen):
        if(self.showBrightness or self.showVolume):
            overlay = pygame.Surface((self.width + 4, self.height + 4),pygame.SRCALPHA)

            backgroundShadow = pygame.Surface(((self.width,self.height)),pygame.SRCALPHA)
            backgroundShadow.fill((0,0,0, 120))
            overlay.blit(backgroundShadow, (4,4))

            background = pygame.Surface((self.width,self.height),pygame.SRCALPHA)
            background.fill((137,137,137, 255))
              

            if(self.showBrightness):
                barWidth =  (self.width - 80) * self.currentBrightnessLevel / 100
          
                if(self.currentBrightnessLevel <= 5):
                    barWidth = 5  
            else:
                barWidth =  (self.width - 80) * self.currentVolumeLevel / 100
                if(self.currentVolumeLevel < 0):
                    barWidth = 1      

            bar = pygame.Surface((barWidth,10))
            bar.fill((255,255,255, 255))

            x = (self.config["screenWidth"] - self.width + 2) / 2
            background.blit(bar, (50,10))

            if(self.showBrightness):
                background.blit(self.brightSymbol, (12,-5)) 
            else:
                background.blit(self.volSymbol, (15,11))                 
            
            overlay.blit(background, (0,0)) 

            overlayCopy = overlay.convert_alpha().copy()

            overlayCopy.fill((255, 255, 255, self.menuAlpha), None, pygame.BLEND_RGBA_MULT)

            screen.blit(overlayCopy, (x,20)) 
开发者ID:JackD83,项目名称:PyMenu,代码行数:42,代码来源:BrightnessVolumeControl.py

示例9: initFooter

# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import BLEND_RGBA_MULT [as 别名]
def initFooter(self):
        self.footer = pygame.Surface((self.config["screenWidth"], self.footerHeight))
        self.footer.fill(self.footerColor)

        leftOffset = 10
        for entry in self.left:
            if(entry[0] != None):
                icon = Common.loadImage(entry[0])
                self.footer.blit(icon, (leftOffset , (self.footerHeight - icon.get_height()) / 2))
                leftOffset = leftOffset + icon.get_width() + self.spacing
            if(entry[1] != None):
                text = self.footerFont.render(entry[1], True, self.textColor)
                self.footer.blit(text, (leftOffset,(self.footerHeight - text.get_height()) / 2))
                leftOffset = leftOffset + text.get_width() + self.spacing
        

        rightOffset = self.config["screenWidth"] - 10 
        for entry in self.right:
            if(entry[1] != None):
                text = self.footerFont.render(entry[1], True, self.textColor)
                self.footer.blit(text, (rightOffset - text.get_width(),(self.footerHeight - text.get_height()) / 2))
                rightOffset = rightOffset - text.get_width() - self.spacing
            if(entry[0] != None):
                icon = Common.loadImage(entry[0])
                icon= icon.convert_alpha().copy()
                icon.fill(self.textColor, None, pygame.BLEND_RGBA_MULT)   
                self.footer.blit(icon, (rightOffset - icon.get_width() , (self.footerHeight - icon.get_height()) / 2))
                rightOffset = rightOffset - icon.get_width() - self.spacing 
开发者ID:JackD83,项目名称:PyMenu,代码行数:30,代码来源:Footer.py

示例10: renderIcons

# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import BLEND_RGBA_MULT [as 别名]
def renderIcons(self, screen):
        powerYPos = self.config["screenHeight"] - 30
        powerXPos = self.config["screenWidth"] - 50
        color = Theme.getColor("main/iconColor", (255,255,255,120))
        colorSelect = Theme.getColor("main/iconColor_select", (255,255,255,255))

        if(self.powerFinal == None):
            
            self.powerFinal = self.power.convert_alpha().copy()
            self.powerFinal.fill(color, None, pygame.BLEND_RGBA_MULT)  
        
        if(self.powerSelect == None):
            self.powerSelect = self.power.convert_alpha().copy()
            self.powerSelect.fill(colorSelect, None, pygame.BLEND_RGBA_MULT)   

               
        if(self.selection == "power"):
            screen.blit(self.powerSelect, (powerXPos,powerYPos))
        else:
            screen.blit(self.powerFinal, (powerXPos,powerYPos))

        settingsYPos = self.config["screenHeight"] - 30
        settingsXPos = 30     

        if(self.gearFinal == None):
            self.gearFinal = self.gear.convert_alpha().copy()
            self.gearFinal.fill(color, None, pygame.BLEND_RGBA_MULT)  

        if(self.gearSelect == None):
            self.gearSelect = self.gear.convert_alpha().copy()
            self.gearSelect.fill(colorSelect, None, pygame.BLEND_RGBA_MULT)  
        
        if(self.selection == "settings"):
            screen.blit(self.gearSelect, (settingsXPos,settingsYPos))
        else:
            screen.blit(self.gearFinal, (settingsXPos,settingsYPos)) 
开发者ID:JackD83,项目名称:PyMenu,代码行数:38,代码来源:MainMenu.py

示例11: render

# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import BLEND_RGBA_MULT [as 别名]
def render(self, screen):
        if(self.waitCopy is None):
            self.waitCopy = self.waitSymbol.convert_alpha().copy()
            self.waitCopy.fill((255, 255, 255, 145), None, pygame.BLEND_RGBA_MULT)

        screen.blit(self.background, (0,0))
        self.renderHeader(screen)
        self.renderSidebar(screen)
  

        if(not self.listReady): 
            x = ( (self.config["screenWidth"] - self.sidebarWidth) / 2 )+ self.sidebarWidth - 16
            y =  (( self.config["screenHeight"] - self.headerHeight) / 2 ) + self.headerHeight - 16
            screen.blit(self.waitCopy, (x, y))
                       
                   
        else:
          
            self.renderEntries(screen)
            self.renderSelection(screen)
            self.renderScrollbar(screen)


        self.renderPreview(screen)
        if(self.footer != None):
            self.footer.render(screen) 
开发者ID:JackD83,项目名称:PyMenu,代码行数:28,代码来源:AbstractList.py

示例12: _fadesurf

# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import BLEND_RGBA_MULT [as 别名]
def _fadesurf(surf, alpha):
	surf = surf.copy()
	asurf = surf.copy()
	asurf.fill((255, 255, 255, int(round(255 * alpha))))
	surf.blit(asurf, (0, 0), None, pygame.BLEND_RGBA_MULT)
	return surf 
开发者ID:ct-Open-Source,项目名称:ct-Raspi-Radiowecker,代码行数:8,代码来源:ptext.py

示例13: blit_mask

# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import BLEND_RGBA_MULT [as 别名]
def blit_mask(self, source_surf, dest_surf, mask):
        mask_rect = mask.get_rect()
        tmp = source_surf.copy()
        tmp.blit(mask, mask_rect.topleft, mask_rect, special_flags=pygame.BLEND_RGBA_MULT)
        dest_surf.blit(tmp, (0, 0), dest_surf.get_rect().clip(mask.get_rect())) 
开发者ID:imiolek-ireneusz,项目名称:eduActiv8,代码行数:7,代码来源:universal.py

示例14: __init__

# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import BLEND_RGBA_MULT [as 别名]
def __init__(self, colour, style, pos, handler=None):
        image = pygame.image.load("assets/elbow.png").convert_alpha()
        # alpha=255
        # image.fill((255, 255, 255, alpha), None, pygame.BLEND_RGBA_MULT)
        if (style == LcarsElbow.STYLE_BOTTOM_LEFT):
            image = pygame.transform.flip(image, False, True)
        elif (style == LcarsElbow.STYLE_BOTTOM_RIGHT):
            image = pygame.transform.rotate(image, 180)
        elif (style == LcarsElbow.STYLE_TOP_RIGHT):
            image = pygame.transform.flip(image, True, False)
        
        self.image = image
        size = (image.get_rect().width, image.get_rect().height)
        LcarsWidget.__init__(self, colour, pos, size, handler)
        self.applyColour(colour) 
开发者ID:tobykurien,项目名称:rpi_lcars,代码行数:17,代码来源:lcars_widgets.py

示例15: render

# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import BLEND_RGBA_MULT [as 别名]
def render(self, text, antialias=False, color=(255,255,255), background=None):
		if not text:
			return None

		ci = [ self.chars[character] for character in text ]

		width = sum( c['xadvance']  for c in ci ) + ci[-1]['xoffset']
		height = max( c['height'] + c['yoffset'] for c in ci )

		surf = pygame.Surface((width, height), flags=pygame.SRCALPHA)


		x = 0

		for c in ci:
			page = self.pages[c['page']]
			w, h = c['width'], c['height']
			sx, sy = c['x'], c['y']
			xofs = c['xoffset']
			yofs = c['yoffset']

			surf.blit(page, (x + xofs, yofs, w, h), (sx, sy, w, h))

			x = x + c['xadvance']
	
		surf.fill(color, special_flags=pygame.BLEND_RGBA_MULT)

		
		if(background): 
			newsurf = pygame.Surface((width, height), flags=pygame.SRCALPHA)
			newsurf.fill(background)
			newsurf.blit(surf, (0,0))
			surf = newsurf

		return surf 
开发者ID:stbnps,项目名称:DanceCV,代码行数:37,代码来源:pygamefont.py


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