Skip to content

Conversation

Tymewalk
Copy link
Member

@Tymewalk Tymewalk commented Jun 1, 2016

Works as follows:

Sprite.isTouching(Sprite)

Uses the colliderect method.

@BookOwl
Copy link
Member

BookOwl commented Jun 1, 2016

Looks good. Add a test before you merge it.

Tymewalk added 2 commits June 1, 2016 11:35
Whoops. I was setting the variable with the function rather than calling the function.
@Tymewalk
Copy link
Member Author

Tymewalk commented Jun 1, 2016

Strange... the test only prints "1".

@Tymewalk Tymewalk self-assigned this Jun 1, 2016
Tymewalk added 3 commits June 1, 2016 11:40
Now it should be more descriptive.
A really long-named function used exactly one, overly-confusing time.
So we can see what's going on.
@Tymewalk
Copy link
Member Author

Tymewalk commented Jun 1, 2016

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 📦

@Tymewalk
Copy link
Member Author

Tymewalk commented Jun 1, 2016

@BookOwl Some testing later, I find that it keeps returning a value of 1 (or printing it, anyways).

I thought colliderect returned a boolean...?

I know what's going on now.
@Tymewalk
Copy link
Member Author

Tymewalk commented Jun 1, 2016

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.

The function works as expected now.
@Tymewalk
Copy link
Member Author

Tymewalk commented Jun 1, 2016

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?

@BookOwl
Copy link
Member

BookOwl commented Jun 1, 2016

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)

@Tymewalk
Copy link
Member Author

Tymewalk commented Jun 2, 2016

@BookOwl I'm not sure, I haven't ever bothered to test. 👅
However, when checking collisions, I create new rects 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.

Tymewalk referenced this pull request Jun 2, 2016
Nobody's going to see them in that little header in __init__.py.
This was referenced Jun 2, 2016
@BookOwl
Copy link
Member

BookOwl commented Jun 2, 2016

The isTouchingTest.py file uses python2 style prints...

@BookOwl
Copy link
Member

BookOwl commented Jun 2, 2016

I fixed the print statements. Other than that, the test looks good. Merging

@BookOwl BookOwl merged commit 9787e92 into master Jun 2, 2016
@BookOwl BookOwl deleted the rectTest branch June 2, 2016 20:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants