#define PX_STEP 8 // How many pixels to move each step |
Well my collision detection system works pretty well except from a small minor problem. My Collision_Check() procedure detects collision as expected, but when retreating from the dense object it returns true 3 more times than needed.
So the output being:
Collision!
Collision!
Collision!
Collision!
As there are 4 collision responses I am assuming this is because 32/8(pixel step size) = 4, that's why I need to take the pixel_x and pixel_y variables in account.
One way around could be making my whole collision check dir-specific but that could get pretty annoying when working with non-cardinal directions such as northeast, northwest, southeast, etc.
I understand how the collision system works but I have a strange feeling I'm not implementing it well, if there are any rewrites needed in my system, especially in the "CollisionCheck()" procedure, then please do say.
Here is a working copy of my movement system (including the source code).
Included in the zip file is a video which shows what problem I am running into.
Thank you.
Haywire
Also, "range(1,src)-src" is the same as "orange(1,src)".