Thread Rating:
  • 1 Vote(s) - 4 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Pixel Collision
#8
(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.
Reply


Messages In This Thread
Pixel Collision - by johnno56 - 04-09-2024, 09:08 AM
RE: Pixel Collision - by johnno56 - 04-09-2024, 11:25 AM
RE: Pixel Collision - by 1micha.elok - 04-09-2024, 03:37 PM
RE: Pixel Collision - by johnno56 - 04-09-2024, 06:21 PM
RE: Pixel Collision - by 1micha.elok - 04-10-2024, 02:04 AM
RE: Pixel Collision - by johnno56 - 04-10-2024, 02:26 AM
RE: Pixel Collision - by 1micha.elok - 04-10-2024, 03:22 AM
RE: Pixel Collision - by kevin - 04-10-2024, 06:52 AM
RE: Pixel Collision - by 1micha.elok - 04-10-2024, 08:05 AM
RE: Pixel Collision - by johnno56 - 04-11-2024, 01:19 AM
RE: Pixel Collision - by kevin - 04-11-2024, 06:14 AM
RE: Pixel Collision - by johnno56 - 04-11-2024, 09:30 AM

Forum Jump:


Users browsing this thread: 2 Guest(s)