Closed Tymewalk closed 8 years ago
Looks good. Add a test before you merge it.
Strange... the test only prints "1".
The current test prints this:
Touching!
<rect(0, 0, 200, 169)>
<rect(0, 0, 200, 169)>
So I'm not sure colliderect
is working properly. Either that or I messed something up :package:
@BookOwl Some testing later, I find that it keeps returning a value of 1
(or printing it, anyways).
I thought colliderect
returned a boolean...?
Never mind that.
I found the problem, it's that the rect
in currentCostume
never actually gets updated. Sprite.xpos
and Sprite.ypos
control it all.
I used a method similar to the blit
function. The function works as expected now.
@BookOwl can you look it over one last time to make sure it looks good?
I'm not sure, but doesn't assigning to a rect's properties move it? I haven't gotten pygame set up on my computer, so I can't test it (yet)
@BookOwl I'm not sure, I haven't ever bothered to test. :tongue:
However, when checking collisions, I create new rect
s that get modified with the properties. They're immediately discarded afterwards.
EDIT: By the way, when I run the test everything works fine. It looks exactly the same as when I don't check for touching.
The isTouchingTest.py file uses python2 style prints...
I fixed the print statements. Other than that, the test looks good. Merging
Works as follows:
Uses the
colliderect
method.