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.