04-10-2024, 06:52 AM
(04-10-2024, 03:22 AM)1micha.elok Wrote:(04-10-2024, 02:26 AM)johnno56 Wrote: Here is something funny... change the 'green' box to 'empty' and see if the white box passes through the "top" of the green box but lands on the "bottom" of the green box... lol
...
Time for lunch... Have a great day!
Hi, I think this issue may be because you are using a floating point number for box.y. If you change the line where you increase this value each cycle to the following, the issue of falling through the top line disappears:
Code:
box.y = int(box.y + box.speed)
It may however then cause issues if box.speed becomes greater than one. One way to workaround that would be to use:
Code:
box.y = int(box.y + min(box.speed,1))
This limits box.speed to 1, so may be too slow for your needs. I'm sure there will be ways round this if needed.
All the best - Kevin.