How do you keep track of what they mean What parts have you implemented so far, whats still missing and are the parts implemented working as intended.I would have been able to give a better review if your code was more readable.
Good code should be readable at first glance, the below variables have no meaning for me. But if you would have divided your code into more functions, the AI can reuse a lot of the functions you created for a single player game, and thus making your code easier to maintain, or add functionality. Provide details and share your research But avoid Asking for help, clarification, or responding to other answers. Making statements based on opinion; back them up with references or personal experience. MathJax reference. To learn more, see our tips on writing great answers. Not the answer youre looking for Browse other questions tagged python beginner game or ask your own question. Its working well (I got some good help on it already), but since Im a beginner in pygame, I would like some feedback from better programmers than me. Anything that improves performance, readability andorganization is welcomed. The github comment is that I dont know if its allowed to just link it from here, so I just copy pasted the code without linking it. To me this looks like copypast other persons work based on your comment. Thats preferred here due to the fact outside link may expire over time. Also, PEP-008 asks that one-line docstrings end with a. Consider moving at least some defs to top level, or creating a SnakeGame class. So much of the game would manipulate food snake in game space coordinates less than GRIDSIZE, and would ask Display to plot points in the much larger screen space. With that in hand, imagine adding one blue pill (food) and one red pill to the board. Eating blue causes Display to flip mirror image around X axis, and red, around Y axis. The rest of your game wouldnt know or care about the visual effect. Consider writing a helper function for gamesound(), to factor out the common expressions. Notepad Snake Game Code Copy And Paste Update The CommentAt some point youll make it 42px Arial font, and then either youll remember to update the comment, or youll have a comment that lies. Put generalities into English language comments, and put specifics into the code. You should add a manifest constant like FONT times new roman. Lists are variable length, unlike tuples. At some point you may support a list of multiple food locations, and the spawn check would test if its length is zero.). Now instead of linear scan you can do a single set membership query. Notepad Snake Game Code Copy And Paste How To Make ConstantsIm not sure how to make constants in python, Ill research, the sys.argv0 was the only way I found to make the path to the songs relative( dont really know what it does). For the direction, youre currently modeling it with four distinct unrelated values, with no relationship between e.g. L R. By using delta x of - 1 the relationship would become clear, and simple arithmetic operations could help you out. Not the answer youre looking for Browse other questions tagged python performance python-3.x pygame snake-game or ask your own question.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |