← الرئيسية
السؤال
اللبنة التالية تتحقق مما إذا كان الكائن يلامس كائن آخر
الإجابة
```python
def touches(self, other):
return (self.x < other.x + other.width and
self.x + self.width > other.x and
self.y < other.y + other.height and
self.y + self.height > other.y)
```
def touches(self, other):
return (self.x < other.x + other.width and
self.x + self.width > other.x and
self.y < other.y + other.height and
self.y + self.height > other.y)
```