本文整理汇总了Python中pygame.Rect.y方法的典型用法代码示例。如果您正苦于以下问题:Python Rect.y方法的具体用法?Python Rect.y怎么用?Python Rect.y使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pygame.Rect
的用法示例。
在下文中一共展示了Rect.y方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_item_at_pos
# 需要导入模块: from pygame import Rect [as 别名]
# 或者: from pygame.Rect import y [as 别名]
def get_item_at_pos (self, position):
"""L.get_item_at_pos (...) -> ListItem
Gets the item at the passed position coordinates.
"""
eventarea = self.rect_to_client ()
if not eventarea.collidepoint (position):
return None
position = position[0] - eventarea.left, position[1] - eventarea.top
border = base.GlobalStyle.get_border_size \
(self.__class__, self.style,
StyleInformation.get ("ACTIVE_BORDER")) * 2
posy = self.vadjustment
items = self.scrolledlist.items
width = eventarea.width
bottom = eventarea.bottom
images = self.images
spacing = self.scrolledlist.spacing
for item in items:
rect = Rect (images [item][1])
rect.y = posy
rect.width = width + border
if rect.bottom > bottom:
rect.height = bottom - rect.bottom + border
if rect.collidepoint (position):
return item
posy += images[item][1].height + spacing + border
return None
示例2: update_body
# 需要导入模块: from pygame import Rect [as 别名]
# 或者: from pygame.Rect import y [as 别名]
def update_body(self):
cell.Cell.update_body(self)
val = self.input("A0") * 1
val += self.input("A1") * 2
val += self.input("A2") * 4
val += self.input("A3") * 8
val += self.input("A4") * 16
val += self.input("A5") * 32
val += self.input("A6") * 64
val += self.input("A7") * 128
h = int(self.rect_rel.height / 3);
pos = Rect(self.rect_rel)
pos.height = h
self.parent.draw_text(self.surface, "%02X" % val, pos)
pos = Rect(self.rect_rel)
pos.y = h * 1
pos.height = h
self.parent.draw_text(self.surface, "%03u" % val, pos)
if (val < 0b01111111):
sig = val
else:
sig = -(256 - val)
pos = Rect(self.rect_rel)
pos.y = h * 2
pos.height = h
self.parent.draw_text(self.surface, "%+04d" % sig, pos)
示例3: update_body
# 需要导入模块: from pygame import Rect [as 别名]
# 或者: from pygame.Rect import y [as 别名]
def update_body(self):
cell.Cell.update_body(self)
h = int(self.rect_rel.height / 4);
pos = Rect(self.rect_rel)
pos.height = h
self.parent.draw_text(self.surface, "MEMORY", pos)
pos = Rect(self.rect_rel)
pos.y = h * 1
pos.height = h
self.parent.draw_text(self.surface, self.filename, pos)
pos = Rect(self.rect_rel)
pos.y = h * 2
pos.height = h
self.parent.draw_text(self.surface, "address: %04X" % self.address, pos)
pos = Rect(self.rect_rel)
pos.y = h * 3
pos.height = h
self.parent.draw_text(self.surface, "data: %02X" % self.data, pos)
示例4: crop_center
# 需要导入模块: from pygame import Rect [as 别名]
# 或者: from pygame.Rect import y [as 别名]
def crop_center(image, size):
rect = Rect((0, 0), size)
res_surf = Surface(size, SRCALPHA, 32)
blit_pos = [0, 0]
if image.get_width() > rect.width:
blit_pos[0] = (-image.get_width()+rect.width) // 2
else:
rect.x = (image.get_width()-rect.width) // 2
if image.get_height() > rect.height:
blit_pos[1] = (-image.get_height()+rect.height) // 2
else:
rect.y = (image.get_height()-rect.height) // 2
print(rect)
print(blit_pos)
res_surf.blit(crop(image, rect), blit_pos)
return res_surf
示例5: makeRooms
# 需要导入模块: from pygame import Rect [as 别名]
# 或者: from pygame.Rect import y [as 别名]
def makeRooms(self):
numRooms = random.randint(NUMROOMSMIN, NUMROOMSMAX)
for roomID in range(numRooms):
attempts = 0
room = Rect(0,0,0,0)
room.width = random.randint(ROOMMIN, ROOMMAX)
room.height = random.randint(ROOMMIN, ROOMMAX)
posFound = False
while not posFound:
if attempts == MAXROOMALLOCATTEMPTS:
#print("Could not resolve room placement for room %i, bailing" % (roomID+1))
break
room.x = random.randint(2, WORLDSIZE[0] - 1)
room.y = random.randint(5, WORLDSIZE[1] - 1)
if (room.x + room.width) >= (WORLDSIZE[0] - 1) or (room.y + room.height) >= (WORLDSIZE[1] - 4):
attempts += 1
continue
posFound = True
for r,w in self.roomInfo:
if r.inflate(2*ROOMSPACING, 2*ROOMSPACING).colliderect(room):
posFound = False
attempts += 1
break
if not posFound:
continue
#Place waypoint
wpX = random.randint(room.x + 1 + int(CORTHICKNESS / 2), room.x + room.width - 1 - int(CORTHICKNESS / 2))
wpY = random.randint(room.y + 1 + int(CORTHICKNESS / 2), room.y + room.height - 1 - int(CORTHICKNESS / 2) )
self.roomInfo.append( (room, (wpX, wpY)) )
for x in range(room.x, room.x + room.width):
for y in range(room.y, room.y + room.height):
self.mapGrid[x][y] = "#"
#Sort rooms in order of Y coordinates
self.roomInfo.sort(key=lambda r: r[0].y)