Пример #1
0
 def isShotClear(self, startPoint, endPoint):
     for terrain in self.mapTerrain:
         if terrain["type"] == "SOLID":
             if mathHelper.rectOnLine(
                 terrain["boundingBox"]["corner"], terrain["boundingBox"]["size"], startPoint, endPoint
             ):
                 return False
     return True
Пример #2
0
def rectOnLine():
    '''
    args: lineStart, lineEnd, rectStartPoint, rectDimensions
    '''
    tester = Tester('rectOnLine')
    rectPos = [5, 5]
    rectSize = [5, 5]

    tester.compare(True,
                   mathHelper.rectOnLine(rectPos, rectSize, [6, 11], [6, 4]))
    tester.compare(True,
                   mathHelper.rectOnLine(rectPos, rectSize, [6, 6], [6, 4]))
    tester.compare(True,
                   mathHelper.rectOnLine(rectPos, rectSize, [6, 11], [7, 4]))
    tester.compare(True,
                   mathHelper.rectOnLine(rectPos, rectSize, [6, 11], [6, 6]))
    tester.compare(True,
                   mathHelper.rectOnLine(rectPos, rectSize, [6, 4], [6, 11]))

    tester.compare(True,
                   mathHelper.rectOnLine(rectPos, rectSize, [11, 9], [6, 4]))
    tester.compare(False,
                   mathHelper.rectOnLine(rectPos, rectSize, [6, 1], [7, 1]))
    tester.compare(False,
                   mathHelper.rectOnLine(rectPos, rectSize, [6, 1], [7, 2]))
    tester.compare(False,
                   mathHelper.rectOnLine(rectPos, rectSize, [9, 1], [15, 6]))
    tester.compare(False,
                   mathHelper.rectOnLine(rectPos, rectSize, [1, 11], [11, 11]))

    tester.compare(False,
                   mathHelper.rectOnLine(rectPos, rectSize, [1, 11], [11, 12]))
Пример #3
0
 def isShotClear(self, startPoint, endPoint):
     for terrain in self.mapTerrain:
         if terrain['type'] == 'SOLID':
             if mathHelper.rectOnLine(terrain['boundingBox']['corner'], terrain['boundingBox']['size'], startPoint, endPoint):
                 return False
     return True
Пример #4
0
def rectOnLine():
    '''
    args: lineStart, lineEnd, rectStartPoint, rectDimensions
    '''
    tester = Tester('rectOnLine')
    rectPos = [5, 5]
    rectSize = [5, 5]

    tester.compare(True, mathHelper.rectOnLine(rectPos, rectSize, [6, 11], [6, 4]))
    tester.compare(True, mathHelper.rectOnLine(rectPos, rectSize, [6, 6], [6, 4]))
    tester.compare(True, mathHelper.rectOnLine(rectPos, rectSize, [6, 11], [7, 4]))
    tester.compare(True, mathHelper.rectOnLine(rectPos, rectSize, [6, 11], [6, 6]))
    tester.compare(True, mathHelper.rectOnLine(rectPos, rectSize, [6, 4], [6, 11]))

    tester.compare(True, mathHelper.rectOnLine(rectPos, rectSize, [11, 9], [6, 4]))
    tester.compare(False, mathHelper.rectOnLine(rectPos, rectSize, [6, 1], [7, 1]))
    tester.compare(False, mathHelper.rectOnLine(rectPos, rectSize, [6, 1], [7, 2]))
    tester.compare(False, mathHelper.rectOnLine(rectPos, rectSize, [9, 1], [15, 6]))
    tester.compare(False, mathHelper.rectOnLine(rectPos, rectSize, [1, 11], [11, 11]))

    tester.compare(False, mathHelper.rectOnLine(rectPos, rectSize, [1, 11], [11, 12]))