Pygame Rect clase
Frecuentes
Visto 1,690 equipos
1 Respuestas
2
Creo que lo que quieres es esto:
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
return (d,t)
Puedes usar esto así:
# Makes a rectangle at (2, 4) with width
# 6 and height 10
rect = new Rectangle((2, 4), 6, 10)
# Returns (8, 14)
bottom_right = rect.get_bottom_right
Además, probablemente podría ahorrarse algo de tiempo haciendo una clase Point
class Point(object):
def __init__(self, x, y):
self.x = x
self.y = y
Respondido 07 Oct 14, 14:10
No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas python class pygame rect or haz tu propia pregunta.
Aunque esto no era exactamente lo que estaba buscando, (casi) resolvió mi problema. 'rect = new Rectangle((2, 4), 6, 10)' no es compatible con python, pero esto también podría ser una falla de mi versión de python. - Berendschot