Example #1
0
    def check_build_line(cls, session, point1, point2, rotation=45, ship=None):
        if point1 == point2:
            # this is actually a masked single build
            return [cls.check_build_fuzzy(session, point1, rotation=rotation, ship=ship)]
        possible_builds = []
        area = Rect.init_from_corners(point1, point2)
        # correct placement for large buildings (mouse should be at center of building)
        area.left -= (cls.size[0] - 1) / 2
        area.right -= (cls.size[0] - 1) / 2
        area.top -= (cls.size[1] - 1) / 2
        area.bottom -= (cls.size[1] - 1) / 2

        xstart, xend = area.left, area.right + 1
        xstep = cls.size[0]
        if point1.x > point2.x:
            xstart, xend = area.right, area.left - 1
            xstep *= -1

        ystart, yend = area.top, area.bottom + 1
        ystep = cls.size[1]
        if point1.y > point2.y:
            ystart, yend = area.bottom, area.top - 1
            ystep *= -1

        for x in xrange(xstart, xend, xstep):
            for y in xrange(ystart, yend, ystep):
                possible_builds.append(cls.check_build(session, Point(x, y), rotation=rotation, ship=ship))
        return possible_builds
Example #2
0
	def check_build_line(cls, session, point1, point2, rotation=45, ship=None):
		if point1 == point2:
			# this is actually a masked single build
			return [cls.check_build_fuzzy(session, point1, rotation=rotation, ship=ship)]
		possible_builds = []
		area = Rect.init_from_corners(point1, point2)
		# correct placement for large buildings (mouse should be at center of building)
		area.left -= (cls.size[0] - 1) // 2
		area.right -= (cls.size[0] - 1) // 2
		area.top -= (cls.size[1] - 1) // 2
		area.bottom -= (cls.size[1] - 1) // 2

		xstart, xend = area.left, area.right + 1
		xstep = cls.size[0]
		if point1.x > point2.x:
			xstart, xend = area.right, area.left - 1
			xstep *= -1

		ystart, yend = area.top, area.bottom + 1
		ystep = cls.size[1]
		if point1.y > point2.y:
			ystart, yend = area.bottom, area.top - 1
			ystep *= -1

		for x in range(xstart, xend, xstep):
			for y in range(ystart, yend, ystep):
				possible_builds.append(
				  cls.check_build(session, Point(x, y), rotation=rotation, ship=ship)
				)
		return possible_builds