Skip to content

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.

@Yijungu Yijungu requested a review from grantjenks November 11, 2022 12:11
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.

2 participants