Conversation
branchwelder
left a comment
There was a problem hiding this comment.
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.
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.
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.
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.
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.
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.
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) |
No description provided.