import pygame.locals
import gameCode.player_ant
import gameCode.soil
pygame.init()
display = pygame.display.set_mode((1280, 720))
displaySurface = pygame.Surface(display.get_size())
clock = pygame.time.Clock()
setPlayerX = 0
setPlayerY = 10
esc = True
playerFlipX = False
playerFlipY = False
mousePosX = 0
mousePosY = 0
soilPosGroupX = list()
soilPosGroupY = list()
soilTag = 0
soilGroup = list()
soilGroupLen = len(soilGroup)
print(soilGroupLen)
pointed = True
checkSoil = 0
soilMouse_betweenX = list()
soilMouse_betweenY = list()
soilMouse_betweenX_abs = list()
soilMouse_betweenY_abs = list()
soilMouse_betweenX_min = 0
soilMouse_betweenY_min = 0
soilMouse_betweenX_min_num = 0
soilMouse_betweenY_min_num = 0
soilMouse_betweenX_Last_min = 0
soilMouse_between_min_pos_soilX = 0
soilMouse_between_min_pos_soilY = 0
def sign(number):
if number > 0:
return True
elif number < 0:
return False
elif number == 0:
return None
while esc:
pygame.display.init()
display.fill((255, 255, 255))
mouseClick1, mouseClick2, mouseClick3 = pygame.mouse.get_pressed()
mousePosX, mousePosY = pygame.mouse.get_pos()
If soilGroupLen > 0: # <-- This part
while pointed:
checkSoil += 1
if checkSoil == soilGroupLen:
soilMouse_betweenX_min = min(soilMouse_betweenX_abs)
soilMouse_betweenY_min = min(soilMouse_betweenY_abs)
soilMouse_betweenX_min_num = soilMouse_betweenX_abs.index(soilMouse_betweenX_min)
soilMouse_between_min_pos_soilX = soilMouse_betweenX_abs.index(soilMouse_betweenX_min)
soilMouse_between_min_pos_soilY = soilMouse_betweenY_abs.index(soilMouse_betweenY_min)
pointX_bool = sign(soilMouse_between_min_pos_soilX)
pointY_bool = sign(soilMouse_between_min_pos_soilY)
pointed = False
soilPosGroupX_out = soilPosGroupX[checkSoil]
soilPosGroupY_out = soilPosGroupY[checkSoil]
soilMouse_betweenX[checkSoil] = mousePosX - soilPosGroupX_out
soilMouse_betweenY[checkSoil] = mousePosY - soilPosGroupY_out
soilMouse_betweenX_abs[checkSoil] = abs(soilMouse_betweenX[checkSoil])
soilMouse_betweenY_abs[checkSoil] = abs(soilMouse_betweenX[checkSoil])
print(soilMouse_betweenX_abs[checkSoil])
print(soilMouse_betweenY_abs[checkSoil]) #<--- Until this part
else:
pass
if mouseClick1 and soilGroupLen == 0:
print(soilGroupLen)
soilTag += 1
soilPosXSet = mousePosX - 50
soilPosYSet = mousePosY - 50
soilPosGroupX.append(soilPosXSet)
soilPosGroupY.append(soilPosYSet)
exec("global soilObject%s" % (soilTag))
exec("soilObject%s = pygame.image.load('image/soil.bmp')" % (soilTag))
exec("soilGroup.append(soilObject%s)" % (soilTag))
elif mouseClick1 and soiGroupLen > 0:
print(soilGroupLen)
soilTag += 1
soilPosXSet = mousePosX - 50
soilPosYSet = mousePosY - 50
soilPosGroupX.append(soilPosXSet)
soilPosGroupY.append(soilPosYSet)
exec("global soilObject%s" % (soilTag))
exec("soilObject%s = pygame.image.load('image/soil.bmp')" % (soilTag))
exec("soilGroup.append(soilObject%s)" % (soilTag))
for event in pygame.event.get():
if event.type == pygame.QUIT:
esc = False
playerObject = gameCode.player_ant.Player(0, playerFlipX, playerFlipY)
playerX, playerFlipX = playerObject.event()
setPlayerX += playerX
display.blit(playerObject.loadImage, (setPlayerX, setPlayerY))
playerRender = pygame.sprite.RenderPlain(playerObject)
playerObject.update()
loopSoilBlit = 0
soilGroupLen = len(soilGroup)
if soilGroupLen > 0:
for loopSoilBlit in range(soilGroupLen):
soilGroup_out = soilGroup[loopSoilBlit]
soilPosGroupX_out = soilPosGroupX[loopSoilBlit]
soilPosGroupY_out = soilPosGroupY[loopSoilBlit]
display.blit(soilGroup_out, (soilPosGroupX_out, soilPosGroupY_out))
else:
pass
pygame.display.flip()
pygame.display.update()
clock.tick(60)
pygame.quit()
ValueError: min() arg is an empty sequence
There's an error, but I don't know what's wrong... Please tell me...
pygame python3.7
soilMouse_betweenX_abs = list()
Assigned an empty list and
soilMouse_betweenX_min = min(soilMouse_betweenX_abs)
Find the min, or minimum, in an empty list, and the message "ValueError: min() arg is an empty sequence" is exported.
In summary, it means that the minimum value cannot be found in an empty list.
© 2024 OneMinuteCode. All rights reserved.