__init__.py 文件源码

python
阅读 28 收藏 0 点赞 0 评论 0

项目:spygame 作者: sven1977 项目源码 文件源码
def move(self, x, y, absolute=False):
        """
        Moves us by x/y pixels (or to x,y if absolute=True).

        :param Union[int,None] x: the amount in pixels to move in x-direction
        :param Union[int,None] y: the amount in pixels to move in y-direction
        :param bool absolute: whether x and y are given as absolute coordinates (default: False): in this case x/y=None means do not move in this dimension
        """
        # absolute coordinates given
        if absolute:
            if x is not None:
                self.rect.x = x
            if y is not None:
                self.rect.y = y
        # do a minimum of 1 pix (if larger 0.0)
        else:
            if 0 < x < 1:
                x = 1
            self.rect.x += x
            if 0 < y < 1:
                y = 1
            self.rect.y += y

        # then we do the boundary checking
        if self.x_max is not None and self.rect.x > self.x_max:
            self.rect.x = self.x_max
        elif self.x_min is not None and self.rect.x < self.x_min:
            self.rect.x = self.x_min

        if self.y_max is not None and self.rect.y > self.y_max:
            self.rect.y = self.y_max
        elif self.y_min is not None and self.rect.y < self.y_min:
            self.rect.y = self.y_min

    # @override(GameObject)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号