-
Notifications
You must be signed in to change notification settings - Fork 8
Final Submission MP4 #5
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
base: master
Are you sure you want to change the base?
Conversation
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.
Looks good overall, I really couldn't find much to comment on!
@@ -0,0 +1,210 @@ | |||
import pygame |
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.
Seeing as this file is not used in your game, you shouldn't commit it with the rest of your work.
TextRect.center = ((display_width/2),(display_height/2)) | ||
screen.blit(TextSurf, TextRect) | ||
|
||
pygame.display.update() |
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.
Style nit: leave space between functions
screen.blit(background_image, (0, 0)) | ||
pygame.display.flip() | ||
|
||
def text_objects(text, font): |
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.
I like that you organized your code into a bunch of different functions rather than cramming it all into the main loop 😺
""" | ||
Define all the inital variables | ||
""" | ||
white = (255, 255, 255) |
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.
By convention, constants are ALL_CAPS e.g. WHITE
.
background_size = (display_width, display_height) | ||
car_size = (100, 67) | ||
|
||
""" |
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 is not a docstring (it's not documenting a module, class, method, or function), so it should be a # comment
instead of a """string"""
.
""" | ||
Initialize the game | ||
""" | ||
pygame.init() |
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.
To take this to the next level, moving the top-level code into a function.
Then you can name the function, which makes the code more readable. For example, if the function is called initialize_game
or init_game
or game_init
, then it's evident what it does even without the comment. Also, this gives you a place to attach the docstring (and examples!), if it is still useful.
This also makes it easier to test the code. This is (mostly) beyond the scope of this class, but it's a good habit to get into.
The global variables would be become attributes of a class, e.g. Game
. The functions below would use e.g. self. barriers_list instead of global barriers_list.
""" | ||
Initialize images | ||
""" | ||
background_colour = (white) |
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.
Parens not necessary.
No description provided.