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

Make pygame display adjust to screen size #17

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Dimi20cen
Copy link
Contributor

@chimosky, kindly review

Make the following adjust to screen size
- Background size
- Squares' and circles' size
- Cars' size
- Font size
- Perceived speed of cars
Comment on lines +231 to 233
if (self.soon_to_draw.x_to_draw > self.middle_of_screen_x and
self.soon_to_draw.object != self.lastright.object):
break
Copy link
Member

Choose a reason for hiding this comment

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

No need for parentheses.

Comment on lines +239 to +240
if (self.soon_to_draw.x_to_draw < self.middle_of_screen_x and
self.soon_to_draw.object != self.lastleft.object):
Copy link
Member

Choose a reason for hiding this comment

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

Here too.

Comment on lines +261 to 262
right_car_right_bound = self.lane_4 - self.car_center
if self.left_moved:
Copy link
Member

Choose a reason for hiding this comment

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

A new line before the condition would be good for code organization.

self.restart, (124, 124)), (550 - 2, 420 - 2))
game.screen.blit(self.scorescreen, (game.background_x, 0))

# Display GAME OVER in the middle of screen
Copy link
Member

Choose a reason for hiding this comment

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

Redundant comment, please remove.

Also remove other redundant comments .ie. comments where the code makes it obvious what's being achieved.

Comment on lines +96 to +101
game.screen.blit(
self.play_button_rescaled, (
game.middle_of_screen_x - (
self.play_dimensions) * 1.1 // 2,
game.screen_height // 2 - (
self.play_dimensions) * 1.1 // 2))
Copy link
Member

Choose a reason for hiding this comment

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

game.screen.blit(
    self.play_button_rescaled,
    game.middle_of_screen_x \
    - (self.play_dimensions * 1.1) // 2,
    game.screen_height // 2 \
    - (self.play_dimensions * 1.1) // 2
)

Seems more readable as we know were the blit starts and ends.

For the grouping of the parentheses, self.play_dimensions being grouped by itself doesn't sit right with me so I'm guessing you multiply and then divide the product of that.

Comment on lines +106 to +108
game.screen.blit(self.play_button, (
game.middle_of_screen_x - (self.play_dimensions) // 2,
game.screen_height // 2 - (self.play_dimensions) // 2))
Copy link
Member

Choose a reason for hiding this comment

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

game.screen.blit(
    self.play_button,
    game.middle_of_screen_x - (self.play_dimensions // 2),
    (game.screen_height // 2) - (self.play_dimensions // 2)
)

Also looks more readable.

# Show Rules screen
else:
game.screen.blit(self.rulescreen, (350, 0))
game.screen.blit(self.rulescreen, (game.background_x, 0))
# Check if start button is hovered
Copy link
Member

Choose a reason for hiding this comment

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

Redundant comment.

Comment on lines +121 to +126
game.screen.blit(
self.play_button_rescaled, (
game.middle_of_screen_x - (
self.play_dimensions) * 1.1 // 2,
game.screen_height * 0.8 - (
self.play_dimensions) * 1.1 // 2))
Copy link
Member

Choose a reason for hiding this comment

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

Would be nice to know where the blit starts and ends.

Comment on lines +130 to +134
game.screen.blit(self.play_button, (
game.middle_of_screen_x - (
self.play_dimensions) // 2,
game.screen_height * 0.8 - (
self.play_dimensions) // 2))
Copy link
Member

Choose a reason for hiding this comment

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

This too, you can look at the changes I made and make it more readable.

@chimosky
Copy link
Member

Reviewed 7929cef, not tested.

@quozl
Copy link
Contributor

quozl commented Apr 25, 2024

Is this fixed by recent Sugargame fix?

@chimosky
Copy link
Member

Quite possible, I'll test to find out.

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

3 participants