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


Python Rect.topleft方法代码示例

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


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

示例1: update_world_window

# 需要导入模块: from pygame import Rect [as 别名]
# 或者: from pygame.Rect import topleft [as 别名]
    def update_world_window(self, screen, floor_s, map_data):
        blit_area = Rect(0,0,64,64)
        # Get the dirty tile -coordinates from map_data
        for dirty_tile_position in map_data.get_dirty_tile_positions:
            # Calculate the screen position for given tile
            dirty_screen_position = screen_position_of_tile(dirty_tile_position)

            area_x, area_y = dirty_tile_position
            blit_area.topleft = (area_x*64, area_y*64)

            # Blit the tile from floor, to screen.
            screen.blit(floor_s, dirty_screen_position, blit_area)
            # Blit items in the tile

            # Try if this position contains a list of items. Note: these may fail :s
            items_in_position = map_data.get_items_on_position(dirty_tile_position)
            if items_in_position is not None:
                self.draw_items_on_tile(screen, items_in_position, dirty_screen_position)

            # Blit character in here.
            character = map_data.get_character_on_position(dirty_tile_position)
            if character is not None:
                screen.blit(character.surface, dirty_screen_position)

        map_data.reset_dirty_tiles()
开发者ID:rytai,项目名称:ReStart,代码行数:27,代码来源:dirty_drawing.py

示例2: test_topleft

# 需要导入模块: from pygame import Rect [as 别名]
# 或者: from pygame.Rect import topleft [as 别名]
 def test_topleft( self ):
     """Changing the topleft attribute moves the rect and does not change
        the rect's size
     """
     r = Rect( 1, 2, 3, 4 )
     new_topleft = (r.left+20,r.top+30)
     old_size = r.size
     
     r.topleft = new_topleft
     self.assertEqual( new_topleft, r.topleft )
     self.assertEqual( old_size, r.size )
开发者ID:CTPUG,项目名称:pygame_cffi,代码行数:13,代码来源:rect_test.py

示例3: get_fill_rect

# 需要导入模块: from pygame import Rect [as 别名]
# 或者: from pygame.Rect import topleft [as 别名]
 def get_fill_rect(self):
     fill_rect = Rect(self.rect)
     fill_rect.topleft = (0,0) # Topleft of the image
     fill_rect.top -= self.rect.height * self.get_percentage_health()
     return fill_rect
开发者ID:Bradshawz,项目名称:lobster,代码行数:7,代码来源:HealthBar.py


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