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


Python Rect.top方法代码示例

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


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

示例1: draw_round_border

# 需要导入模块: from pygame import Rect [as 别名]
# 或者: from pygame.Rect import top [as 别名]
def draw_round_border(surface, width=4, color=None, bounds=None):
    """draw_round_border(Surface, line_width, Color, Rect) => None
       only Surface is required"""
    h = surface.get_height()
    w = surface.get_width()
    img = dialog.circle_border_image
    if color == None: color = pygame.color.Color("white")
    if bounds == None: bounds = surface.get_rect()

    r = Rect(0,0,8,8)
    border = bounds.inflate(-8,-8)
    border.topleft = bounds.topleft

    surface.blit(img, border.topleft, r)
    r.top = 8
    surface.blit(img, border.bottomleft, r)
    r.left = 8
    surface.blit(img, border.bottomright, r)
    r.top = 0
    surface.blit(img, border.topright, r)
    
    i = bounds.inflate(-17,-17)
    o = bounds.inflate(-3,-3)
    o.topleft = bounds.topleft
    draw.line(surface, color, (i.left,o.top),(i.right,o.top),       4 )
    draw.line(surface, color, (o.left,i.top),(o.left,i.bottom),     4 )
    draw.line(surface, color, (i.left,o.bottom),(i.right,o.bottom), 4 )
    draw.line(surface, color, (o.right,i.top),(o.right,i.bottom),   4 )
开发者ID:bpa,项目名称:renegade,代码行数:30,代码来源:dialog.py

示例2: create_platforms_rect

# 需要导入模块: from pygame import Rect [as 别名]
# 或者: from pygame.Rect import top [as 别名]
	def create_platforms_rect(self, tiles, layer):
		""" Create a collision rect for each non-empty tile segment, that is, one or more tiles together """
		if len(tiles) < 1:
			return False

		x, y = tiles.pop(0)
		width = self.map.content['tilewidth']
		height = self.map.content['tileheight']
		rect = Rect((0, 0, 0, 0))
		rect.left = x * width
		rect.top = y * height
		rect.width = width
		rect.height = height
		# self.platforms.append(Platform(rect, layer))
		n_tiles_x, n_tiles_y = 0, 0

		# exclude the tiles we're about to create a platform for
		excluded_tiles = []
		for (n_x, n_y) in tiles:
			if abs(n_x - x) == n_tiles_x and n_y == y:
				rect.width += width
				n_tiles_x += 1
				excluded_tiles.append((n_x, n_y))
			if abs(n_y - y) == n_tiles_y and n_x == x:
				rect.height += height
				n_tiles_y += 1
				excluded_tiles.append((n_x, n_y))

		self.platforms.append(Platform(rect, layer))
		self.create_platforms_rect([t for t in tiles if not t in excluded_tiles], layer)
开发者ID:glhrmfrts,项目名称:rgb,代码行数:32,代码来源:physics.py

示例3: scroll_up_rect

# 需要导入模块: from pygame import Rect [as 别名]
# 或者: from pygame.Rect import top [as 别名]
 def scroll_up_rect(self):
     d = self.scroll_button_size
     r = Rect(0, 0, d, d)
     m = self.margin
     r.top = m
     r.right = self.width - m
     r.inflate_ip(-4, -4)
     return r
开发者ID:codewarrior0,项目名称:mcedit,代码行数:10,代码来源:palette_view.py

示例4: drawDebugRects

# 需要导入模块: from pygame import Rect [as 别名]
# 或者: from pygame.Rect import top [as 别名]
		def drawDebugRects(sgroup, color_cb):
			for s in (sgroup):
				color = color_cb(s)
								
				srect = Rect(s.rect)
				srect.left += self.scenebuf_delta_x
				srect.top = self.GAME_HEIGHT - 50
				self.backbuf.fill(color, srect)
开发者ID:ld35-europa,项目名称:europa,代码行数:10,代码来源:GameWorld.py

示例5: test_top

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

示例6: get_bullet_image

# 需要导入模块: from pygame import Rect [as 别名]
# 或者: from pygame.Rect import top [as 别名]
def get_bullet_image(index, w=16, h=16):
    global bullet_image
    if not bullet_image:
        bullet_image = image.load(resource_path(config.nbtTreeSettings.bulletFileName.get()))
    r =  Rect(0, 0, w, h)
    line_length = int(bullet_image.get_width() / w)
    line = int(index / line_length)
    r.top = line * h
    r.left = (index - (line * line_length)) * w
    return bullet_image.subsurface(r)
开发者ID:vongola12324,项目名称:MCEdit-Unified,代码行数:12,代码来源:nbtexplorer.py

示例7: draw

# 需要导入模块: from pygame import Rect [as 别名]
# 或者: from pygame.Rect import top [as 别名]
    def draw(self):
        #First draw container rect,then draw text rect inside it
        self.text_surface= self.font.render(self.text, True,self.font_color,self.bgcolor)
        self.text_size=self.text_surface.get_size()
        container_rect=Rect(self.x_y[0]-self.border_width,self.x_y[1] - self.border_width,self.text_size[0] + self.border_width,self.text_size[1]+self.border_width)
        container_rect.top=self.x_y[1]
        container_rect.left=self.x_y[0]
        self.text_dest=self.x_y+(self.border_width,self.border_width)

        pygame.draw.rect(self.surface,self.border_color,container_rect)
        self.surface.blit(self.text_surface,self.text_dest)
开发者ID:DonyTawil,项目名称:Tetris--pygame-,代码行数:13,代码来源:widgets.py

示例8: sin

# 需要导入模块: from pygame import Rect [as 别名]
# 或者: from pygame.Rect import top [as 别名]
        ang, distance = self.angle, self.speed
        return sin(ang) * distance, cos(ang) * distance
  
    def collide(self):
        angle = self.angle
        x, y = self.center
        radius = self.get_radius()
        rect = Rect(x - radius, y - radius, radius * 2, radius * 2)
        bandit = self.parent.bandit.rect
        if rect.colliderect(bandit):
            if bandit.left - rect.right > rect.top - bandit.bottom:
                angle = -angle
                rect.right = bandit.left
            else:
                angle = pi - angle
                rect.top = bandit.bottom
        field = self.parent.rect
        if rect.right > field.w or rect.left < 0:
            angle = -angle
            if rect.right > field.w:
                rect.right = field.w
            else:
                rect.left = 0
        if rect.top < 0 or rect.bottom > field.h:
            angle = pi - angle
            if rect.top < 0:
                rect.top = 0
            else:
                rect.bottom = field.h
        self.angle = angle
        self.center = rect.center
开发者ID:eduardogpg,项目名称:Juego_Samurai,代码行数:33,代码来源:PyagameOficial.py

示例9: __contains__

# 需要导入模块: from pygame import Rect [as 别名]
# 或者: from pygame.Rect import top [as 别名]
 def __contains__(self, event):
     r = Rect(self._rect)
     r.left = 0
     r.top = 0
     p = self.global_to_local(event.pos)
     return r.collidepoint(p)
开发者ID:18986064,项目名称:mcedit,代码行数:8,代码来源:widget.py

示例10: resource_path

# 需要导入模块: from pygame import Rect [as 别名]
# 或者: from pygame.Rect import top [as 别名]
            bullet_image = image.load(resource_path(config.nbtTreeSettings.bulletFileName.get()))
        except Exception, e:
            print "*** MCEDIT DEBUG: bullets image could not be loaded."
            print "*** MCEDIT DEBUG:", e
            print "*** MCEDIT DEBUG: bullets image file:", resource_path(config.nbtTreeSettings.bulletFileName.get())
            print "*** MCEDIT DEBUG: current directory:", os.getcwd()
            from pygame import Surface, draw, SRCALPHA
            bullet_image = Surface((64, 64), SRCALPHA)
            bullet_image.fill((0, 0, 0, 0))
            for i in range(4):
                for j in range(4):
                    bullet_image.fill((255/(i or 1), 255/(j or 1), 255, 255), [16*i, 16*j, 16*i+16, 16*j+16])
    r = Rect(0, 0, w, h)
    line_length = int(bullet_image.get_width() / w)
    line = int(index / line_length)
    r.top = line * h
    r.left = (index - (line * line_length)) * w
    return bullet_image.subsurface(r)


default_bullet_styles = {TAG_Byte: ((20, 20, 200), None, 'circle', 'b'),
                         TAG_Double: ((20, 200, 20), None, 'circle', 'd'),
                         TAG_Float: ((200, 20, 20), None, 'circle', 'f'),
                         TAG_Int: ((16, 160, 160), None, 'circle', 'i'),
                         TAG_Long: ((200, 20, 200), None, 'circle', 'l'),
                         TAG_Short: ((200, 200, 20), (0, 0, 0), 'circle', 's'),
                         TAG_String: ((60, 60, 60), None, 'circle', 's'),
                         TAG_Compound: (bullet_color_active, None, '', ''),
                         TAG_Byte_Array: ((20, 20, 200), None, 'square', 'B'),
                         TAG_Int_Array: ((16, 160, 160), None, 'square', 'I'),
                         TAG_List: ((200, 200, 200), (0, 0, 0), 'square', 'L'),
开发者ID:BossosaurusRex,项目名称:MCEdit-Unified,代码行数:33,代码来源:nbtexplorer.py

示例11: main

# 需要导入模块: from pygame import Rect [as 别名]
# 或者: from pygame.Rect import top [as 别名]
def main():

    pygame.init()
    pantalla=pygame.display.set_mode((800,600))
    pygame.FULLSCREEN


    pygame.display.set_caption("ProyectoPygame")
    reloj1=pygame.time.Clock()
    salir=False

    p1 = Personaje()
    p1._x = 430
    p1._y = 180
    p1.x_antes = 50
    p1.y_antes = 50
    p1.tam_rectangulos((70, 70))
    p1.actualizacionRec()

    p2 = Personaje()
    p2._x = 100
    p2._y = 200
    p2.tam_rectangulos((100, 100))
    p2.actualizacionRec()

    plataforma2 = Plataforma()
    plataforma2.setXY(250, 200)
    plataforma2.setTamRect(300, 100)

    p1_antes = Rect(p1.x_antes, p1.y_antes, 70, 70)

    motor = MotorVideojuego()
    motor.conjuntoPersonajes = [p1, p2]
    #motor.start()
    start = pygame.time.get_ticks()/1000

    iter=0
    limit=1000

    l = reposicion(p1, plataforma2)
    while salir == False:

        lista=pygame.event.get()#((pygame.KEYDOWN, pygame.KEYUP, pygame.QUIT, pygame.MOUSEBUTTONDOWN))
        for event in lista:
            #----------Escuchando Eventos del Usuario-#
            if event.type == pygame.QUIT:
                salir = True
            if event.type == pygame.MOUSEBUTTONDOWN:
                if event.button == 1:
                    p1.setSalto(True)
                    print "SAlta"
            if event.type == pygame.MOUSEMOTION:
                xy=pygame.mouse.get_pos()
                p1.x_antes = xy[0]
                p1.y_antes = xy[1]
                p1_antes.left = xy[0]
                p1_antes.top = xy[1]
                l = reposicion(p1, plataforma2)

        pantalla.fill((0,0,240))
        if pygame.time.get_ticks()>limit:
            #print iter
            limit+=1000
            iter=0
        iter+=1



        pygame.draw.rect(pantalla, green, plataforma2.rectangulo)
        pygame.draw.rect(pantalla, red, p1.rectangulo)
        pygame.draw.rect(pantalla, red, p1_antes)

        for rec in l:
            pygame.draw.rect(pantalla, darkBlue, rec)


        reloj1.tick(120)
        pygame.display.update()
    motor.salirJuego = True
    pygame.quit()
开发者ID:danielx25,项目名称:ProyectoPlataforma,代码行数:82,代码来源:ejemploReposicion.py


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