本文整理汇总了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()
示例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 )
示例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