-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rectangle collision algorithm #75
Conversation
Even though it says it passed some unit tests are failing, you can click on the show all checks and it'll give you details |
game/common/hitbox.py
Outdated
from game.common.enums import * | ||
|
||
|
||
class Hitbox(GameObject): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This version of hit box is outdated. Please pull dev again !
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couple of minor suggestions, but it seems logically sound
self.hitOne = Hitbox(10, 10, (5, 5)) | ||
self.hitTwo = Hitbox(25, 25, (5, 6)) | ||
|
||
"""Below are 3 examples of true cases and false cases. The hit boxes were graphed out beforehand |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tests shouldn't need docstrings, but it doesn't really matter
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in other words this can just be a regular comment using #... format instead of """...""" format
game/utils/collision_detection.py
Outdated
if (hitbox_one.topLeft[0] < hitbox_two.topRight[0] and | ||
hitbox_one.topRight[0] > hitbox_two.topLeft[0] and | ||
hitbox_one.topLeft[1] < hitbox_two.bottomLeft[1] and | ||
hitbox_one.bottomRight[1] > hitbox_two.topRight[1]): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
instead of doing an if here you can instead just do
return hitbox_one.topLeft[0] < hitbox_two.topRight[0] and
hitbox_one.topRight[0] > hitbox_two.topLeft[0] and
hitbox_one.topLeft[1] < hitbox_two.bottomLeft[1] and
hitbox_one.bottomRight[1] > hitbox_two.topRight[1]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah yeah, I forgot I could just do that XD. I'll make those minor syntax changes next commit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good!
closes #34
Edit: This branch can be merged once approved