python类Rect()的实例源码

bullet.py 文件源码 项目:Pythonlearn 作者: godzoco 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def __init__(self, ai_settings, screen, ship):
        """??????????"""
        #super(Bullet, self).__init__() ???2.7??  ?? 3.0?? ??
        super().__init__()
        self.screen = screen

#class Foo():   ?????????
#    def __init__(self, frob, frotz)
#        self.frobnicate = frob
#        self.frotz = frotz

#class Bar(Foo):
#    def __init__(self, frob, frizzle)
#        super().__init__(frob, 34)
#        self.frazzle = frizzle

        # ??0.0???????????????????.
        self.rect = pygame.Rect(0, 0, ai_settings.bullet_width,
            ai_settings.bullet_height)
        self.rect.centerx = ship.rect.centerx
        self.rect.top = ship.rect.top

        # ???????????
        self.y = float(self.rect.y)

        self.color = ai_settings.bullet_color
        self.speed_factor = ai_settings.bullet_speed_factor
        #???? ????? ??? pygame.rect() ??????????
        #?? ?????????? X Y ??  ?? ?? ????? ????? ?settings ????

        #rect.centerx ??????????
        #rect.top ????????????
bullet.py 文件源码 项目:Pythonlearn 作者: godzoco 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def update(self):
        """??????."""
        # ??????????. ????????            ???????
        self.y -= self.speed_factor
        # ?? rect ??. ????????
        self.rect.y = self.y
bullet.py 文件源码 项目:Pythonlearn 作者: godzoco 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
def draw_bullet(self):
        """???????."""
        pygame.draw.rect(self.screen, self.color, self.rect)

        #?draw.recct() ???self.color????????rect ???????
Tile.py 文件源码 项目:AIFun 作者: Plottel 项目源码 文件源码 阅读 32 收藏 0 点赞 0 评论 0
def rect(self):
        return Rect(self.x, self.y, Tile.width, Tile.height)
Tile.py 文件源码 项目:AIFun 作者: Plottel 项目源码 文件源码 阅读 32 收藏 0 点赞 0 评论 0
def render(self):
        pygame.draw.rect(Renderer.SCREEN, self.color, self.rect, 0)
Tileset.py 文件源码 项目:AIFun 作者: Plottel 项目源码 文件源码 阅读 31 收藏 0 点赞 0 评论 0
def rect(self):
        return Rect(self.x, self.y, self.width, self.height)

    # Initialises the Tileset and adds columns and rows
Tileset.py 文件源码 项目:AIFun 作者: Plottel 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def is_at(self, x, y):
        return self.rect.collidepoint(x, y)

    # Specifies if the Tileset is at the current mouse position
Tileset.py 文件源码 项目:AIFun 作者: Plottel 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
def render(self):
        for col in range(self.cols):
            for row in range(self.rows):
                self.tiles[col][row].render()

                if self.show_grid:
                    pygame.draw.rect(Renderer.SCREEN, Renderer.COLOR_BLACK, self.tiles[col][row].rect, 1)
Entity.py 文件源码 项目:AIFun 作者: Plottel 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def render(self):
        pygame.draw.rect(Renderer.SCREEN, self.color, self.rect, 0)
Pickups.py 文件源码 项目:AIFun 作者: Plottel 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def rect(self):
        return Rect(self.x, self.y, self.size, self.size)


问题


面经


文章

微信
公众号

扫码关注公众号