Nov-16-2023, 06:28 AM
Your code layout is not readable. Put imports at the very top of the file. Group functions and classes near top of the file. Put the main body of code at the bottom of the file. Use 2 blank lines after each function and after each class. Those are all python programming conventions that are widely used.
In addition, classes should have a doc string describing what the class is, and methods should have a doc string that describes what they do. Comments should be few. If the code is difficult to understand, reorganize the code so it is easy to understand instead of using many comments. And don't fill you code with useless comments. When I see a comment I expect the comment to tell me information that I cannot get from reading the code. These comments don't provide any additional information.
In addition, classes should have a doc string describing what the class is, and methods should have a doc string that describes what they do. Comments should be few. If the code is difficult to understand, reorganize the code so it is easy to understand instead of using many comments. And don't fill you code with useless comments. When I see a comment I expect the comment to tell me information that I cannot get from reading the code. These comments don't provide any additional information.
# Carica l'immagine del mirino mirino = pygame.image.load("C:\\ProgramData\\ProgramPy\\mirino.png") # Crea uno sprite per il mirino sprite_mirino = pygame.sprite.Sprite()Nor these:
self.speedx = ENEMY_SPEED # La velocità orizzontale del nemico self.speedy = ENEMY_SPEED # La velocità verticale del nemico