That line is giving you the error because plat_index
is actually a float. Assuming your capitalized constants are integers, self.pos[1]
must be a float. You'll have to look farther back in your code to see how that number was generated. As a short-term workaround, just use int()
:
plat_index = min(int(self.pos[1]) // PLATFORM_SPACING, NUM_PLAT - 1)
Or, you could call int()
on the whole thing, just to be sure:
plat_index = int(min(self.pos[1] // PLATFORM_SPACING, NUM_PLAT - 1))
Also, as a side note, the line timer+1
doesn't actually do anything, because it doesn't store the resulting value anywhere.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…