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

Overlap game #90

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open

Overlap game #90

wants to merge 6 commits into from

Conversation

Yijungu
Copy link

@Yijungu Yijungu commented Nov 4, 2022

Overlap game is a game of fitting a moving square to a fixed square frame.
If you succeed in this mission, your score will go up.
The square and square frame get smaller and smaller.

I'd appreciate it if you could give me a feed. thanks

Copy link
Owner

@grantjenks grantjenks left a comment

Choose a reason for hiding this comment

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

I tried playing the game but it wasn't clear what the goal is.

I also think there may be some bugs. Try playing the game more and adding tests (as the other games have).

top_size = {0: 300, 1: 200}


def rectangle_top(x, y, size):
Copy link
Owner

Choose a reason for hiding this comment

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

Use a more descriptive name. What does "top" mean?

left(90)


def rectangle_move(x, y, size):
Copy link
Owner

Choose a reason for hiding this comment

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

Refactor the repeated code between rectangle_move and rectangle_top

Comment on lines 18 to 19
top = {0: vector(0, 0)}
top_size = {0: 300, 1: 200}
Copy link
Owner

Choose a reason for hiding this comment

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

Should these be dictionaries or lists? Seems like only the last value is ever deleted.

Comment on lines 83 to 86
if top[len(top) - 1].x - top_size[len(top) - 1] / 2 < top[len(top) - 2].x - top_size[len(top) - 2] / 2 or \
top[len(top) - 1].y - top_size[len(top) - 1] / 2 < top[len(top) - 2].y - top_size[len(top) - 2] / 2 or \
top[len(top) - 1].x + top_size[len(top) - 1] / 2 > top[len(top) - 2].x + top_size[len(top) - 2] / 2 or \
top[len(top) - 1].y + top_size[len(top) - 1] / 2 > top[len(top) - 2].y + top_size[len(top) - 2] / 2:
Copy link
Owner

Choose a reason for hiding this comment

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

This expression is much too complex. Break these lines into separate parts/variables.

Also, the use of backslash in Python code should be discouraged. Break long lines into more readable parts and use parens instead only if you must.

@Yijungu
Copy link
Author

Yijungu commented Nov 8, 2022

Changes:

  1. The goal of the game is to make the size of the rectangle zero. you can change the target size by touching the variable:goal_size.
  2. top -> overlap. indicate the steps of overlap
  3. The common code in the middle was made into other function.
  4. The rectangle size was calculated through the length of the overlap. The variable:default_size is the size of the starting rectangle frame.
  5. Variables and conditional statements are organized separately.

Thank you very much for feedback.
If you have any feedback, I would be really grateful if you could tell me.

Copy link
Author

@Yijungu Yijungu left a comment

Choose a reason for hiding this comment

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

I posted the second game incorrectly here.
Sorry for the confusion.

@grantjenks
Copy link
Owner

Can you record a video of you playing the game and share it? I tried playing it again but a black square just flickers up and down. I don't get it.

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.

None yet

2 participants