python - Pygame Rect class -
how define rectangular class in pygame?
class square(pygame.rect) def __init__(self): pygame.rect.__init__(self)
the code above, utilize define sprite class doesn't work.
i think want this:
class rectangle(object): def __init__(self, top_corner, width, height): self._x = top_corner[0] self._y = top_corner[1] self._width = width self._height = height def get_bottom_right(self): d = self._x + self.width t = self._y + self.height homecoming (d,t)
you can utilize this:
# makes rectangle @ (2, 4) width # 6 , height 10 rect = new rectangle((2, 4), 6, 10) # returns (8, 14) bottom_right = rect.get_bottom_right
also, save time making point class
class point(object): def __init__(self, x, y): self.x = x self.y = y
python class pygame rect
No comments:
Post a Comment