Beispiel #1
0
 def get_corners(self):
     top_left = self.corner
     top_right = Point(self.corner.x + self.width, self.corner.y)
     bottom_left = Point(self.corner.x, self.corner.y - self.height)
     bottom_right = Point(self.corner.x + self.width,
                          self.corner.y - self.height)
     return [top_left, top_right, bottom_left, bottom_right]
Beispiel #2
0
from Week_1.Chapter_11.section_1_12.point import Point
from Week_1.Chapter_11.section_2_6.rectangle import Rectangle

target = Rectangle(Point(0, 5), 10, 5)
bullet = Rectangle(Point(10, 1), 1, 1)

print(target.collide(bullet))
Beispiel #3
0
from Week_1.Chapter_11.section_1_12.point import Point

p = Point(20, 20)
q = Point(15, 15)
r = Point(20, 10)
s = Point(25, 15)

west = min(p.x, q.x, r.x, s.x)
east = max(p.x, q.x, r.x, s.x)
north = max(p.y, q.y, r.y, s.y)
south = min(p.y, q.y, r.y, s.y)

x = (west + east) / 2
y = (south + north) / 2

print(x, y)
Beispiel #4
0
from Week_1.Chapter_11.section_1_12.point import Point
from Week_1.Chapter_11.section_2_6.rectangle import Rectangle

r = Rectangle(Point(0, 0), 20, 15)

r.area()
print(r.area())
from Week_1.Chapter_11.section_1_12.point import Point
from Week_1.Chapter_11.section_2_6.rectangle import Rectangle

r = Rectangle(Point(0, 0), 10, 5)

print(r.contains(Point(0, 0)))
print(r.contains(Point(3, 3)))
print(not r.contains(Point(3, 7)))
print(not r.contains(Point(3, 5)))
print(r.contains(Point(3, 4.999)))
print(not r.contains(Point(-3, -3)))