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


Python Rect.y方法代码示例

本文整理汇总了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
开发者ID:BGCX067,项目名称:eyestabs-svn-to-git,代码行数:33,代码来源:ListViewPort.py

示例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)
开发者ID:fhorinek,项目名称:pi8bit,代码行数:33,代码来源:outputs.py

示例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)
开发者ID:fhorinek,项目名称:pi8bit,代码行数:24,代码来源:memory.py

示例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
开发者ID:CyboticCatfish,项目名称:code404-server,代码行数:20,代码来源:image.py

示例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)
开发者ID:nojan1,项目名称:closeQuarters,代码行数:46,代码来源:levelgen.py


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