Skip to content
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

Merged
merged 13 commits into from
Jul 8, 2021
Merged

Rectangle collision algorithm #75

merged 13 commits into from
Jul 8, 2021

Conversation

amanda-f-ndsu
Copy link
Collaborator

@amanda-f-ndsu amanda-f-ndsu commented Jun 29, 2021

closes #34

Edit: This branch can be merged once approved

@amanda-f-ndsu amanda-f-ndsu added the wait for author Used for when a PR isn't ready for review yet label Jun 29, 2021
@amanda-f-ndsu amanda-f-ndsu linked an issue Jun 29, 2021 that may be closed by this pull request
@erickbickler
Copy link
Collaborator

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

from game.common.enums import *


class Hitbox(GameObject):
Copy link
Owner

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 !

@amanda-f-ndsu amanda-f-ndsu removed the wait for author Used for when a PR isn't ready for review yet label Jul 6, 2021
Copy link
Collaborator

@erickbickler erickbickler left a 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
Copy link
Collaborator

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

Copy link
Collaborator

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

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]):
Copy link
Collaborator

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]

Copy link
Collaborator Author

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.

@amanda-f-ndsu amanda-f-ndsu requested a review from HagenSR July 7, 2021 00:42
Copy link
Owner

@HagenSR HagenSR left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good!

@HagenSR HagenSR merged commit dfeba27 into dev Jul 8, 2021
@HagenSR HagenSR deleted the Rectangle-Collision-Algorithm branch July 8, 2021 20:40
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.

Create Collision Algorithm
4 participants