简体   繁体   中英

how do i find the greatest length from a given point and make the program stop after that point with the greatest length hits the middle?

My program makes 30 randomly generated points that spawn from the edge of the map that move towards the center. My program works fine, but how would I find the largest length of these points and then say "if the largest length hits the middle, reset?

I just dont know how

biggestLength = 0

lengthList = []
after = 1

length = math.sqrt(dx * dx + dy * dy)

lengthList.append(length)
biggestLength = lengthList[0]
if len(lengthList) == 30:
    while x < 30:
        if lengthList[after] > biggestLength:
            lengthList[after] = biggestLength
        after += 1
        x += 1
    lastWaste = lengthList.index(biggestLength)
    print (biggestLength)
    lengthList = []

列表的最大值可以通过max获得:

biggestLength = max(lengthList)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM