Skip to content

Add isTouching() method - #61

Merged
BookOwl merged 9 commits into
masterfrom
rectTest
Jun 2, 2016
Merged

BookOwl merged 9 commits into
masterfrom
rectTest

Conversation

@Tymewalk

@Tymewalk Tymewalk commented Jun 1, 2016

Copy link
Copy Markdown
Member

Works as follows:

Sprite.isTouching(Sprite)

Uses the colliderect method.

@BookOwl

BookOwl commented Jun 1, 2016

Copy link
Copy Markdown
Member

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

Tymewalk commented Jun 1, 2016

Copy link
Copy Markdown
Member Author

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

Tymewalk commented Jun 1, 2016

Copy link
Copy Markdown
Member Author

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

Tymewalk commented Jun 1, 2016 •

Copy link
Copy Markdown
Member Author

@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

Tymewalk commented Jun 1, 2016

Copy link
Copy Markdown
Member Author

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

Tymewalk commented Jun 1, 2016

Copy link
Copy Markdown
Member Author

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

BookOwl commented Jun 1, 2016

Copy link
Copy Markdown
Member

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

Tymewalk commented Jun 2, 2016 •

Copy link
Copy Markdown
Member Author

@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

BookOwl commented Jun 2, 2016

Copy link
Copy Markdown
Member

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

@BookOwl

BookOwl commented Jun 2, 2016

Copy link
Copy Markdown
Member

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