Skip to main content
47 votes

Beginner's snake game using PyGame

PEP 8 PEP 8 recommends that constants be written as "all capital letters with underscores separating words.". So something like: yellow = (255, 255, 0) Should ...
Dair's user avatar
  • 5,906
24 votes

Beginner's snake game using PyGame

In addition to another answer I will add these places to improve (I will not repeat all things from that answer, my answer is just an addition): 1. Code inconsistency You have several places in your ...
vurmux's user avatar
  • 1,355
22 votes
Accepted

Planetary simulation in python

Use a vector type to store positions, velocities and forces Instead of writing out all the calculations for the x and y direction separately, consider using a library that provides you with vector ...
G. Sliepen's user avatar
  • 58.3k
12 votes
Accepted

Using the mouse to avoid asteroids and black holes

Is this good enough to show this as an example of my...skills for very entry level job in programming? No At least this was my reaction after reading the first few lines of code: you don't just ...
301_Moved_Permanently's user avatar
12 votes
Accepted

Counting people inside the house game

You're right - there is a lot of duplication. Also, some organization is needed. Organize! Before you do anything else, get everything into a function of some kind. All those statements at module ...
aghast's user avatar
  • 12.4k
11 votes

How can I get my CPU Utilization Down? PYGAME PROJECT

The code is not easy to run because I don't have your local files. However, I was able to throw some together in MS Paint. Although I didn't notice any performance issues (you might need to update ...
Justin Chang's user avatar
10 votes

Beginner's snake game using PyGame

size: int ... self.size = 2 You never read size, and Python Lists already know their own length in case you did need ...
Peter Cordes's user avatar
  • 3,346
10 votes
Accepted

Gomoku (Connect 5) game implementation in pygame

On the whole, this game works nicely and the design decisions make sense for the size and purpose of the program. Variable names are clear, there's some separation between GUI and game logic and you'...
ggorlen's user avatar
  • 3,670
9 votes
Accepted

Beginner grid-based game movement engine

Styling Python has its own official style guide (written by the author of Python) called PEP 8. It has some things to say about your code. By the way, you can check your code against PEP 8 by ...
zondo's user avatar
  • 3,797
9 votes

Simple PyGame Connect 4

Space ...
AJNeufeld's user avatar
  • 33.8k
9 votes

Planetary simulation in python

TL;DR: I created a Github project with everything I suggested and more (like taking all PyGame-related logic away from the Planet class, leaving it only with planet-related logic). Take a look at the ...
KiriSakow's user avatar
  • 191
9 votes
Accepted

Space shooter game using pygame

The graphics are beautiful. I appreciate the attention to details, like the background stars. assets directory This certainly is not bad: ...
J_H's user avatar
  • 29.5k
9 votes
Accepted

Is this Python/Pygame that draws a maze well structured?

The structure looks great. In particular, each method is small, and its single responsibility is clear. Also there's a nice __main__ guard, so unit tests can safely ...
J_H's user avatar
  • 29.5k
8 votes
Accepted

Raycasting algorithm in pygame

Python is not a fast language — it trades execution speed for flexibility and introspectability — and the kind of repetitive numerical computation involved in CPU rendering is pretty much the worst ...
Gareth Rees's user avatar
  • 49.6k
8 votes
Accepted

First chess game

Your function initialize_piece could be way simpler if you used a dictionary to map from the piece rank to the file name and used ...
Graipher's user avatar
  • 41k
8 votes
Accepted

Memory Game using Tkinter/Pygame

Most of your inline comments are useless I see lots of comments like this: def login_button(): # Defines login_button That comment adds no information. It just ...
Bryan Oakley's user avatar
  • 2,089
7 votes

First Python program: Snake

For efficiency reasons, you should always do x1**2 + y1**2 < r**2 rather than sqrt(x1**2 + y1**2) < r, because ...
Benoît P's user avatar
  • 799
7 votes
Accepted

Golf game boilerplate

Some of this is nit-pickery, some is more fundamental: Import Order PEP-8 suggests an ordering to imports. No reason not to use it: Imports should be grouped in the following order: ...
aghast's user avatar
  • 12.4k
7 votes

Gomoku (Connect 5) game implementation in pygame

I can suggest a small improvement when you are checking the win with the code: ...
Caridorc's user avatar
  • 27.5k
6 votes
Accepted

Simple 'Space Invaders' clone

Just a minor improvements. 1) If you count something manually or repeat exact lines one after other probably you do something wrong. Use iteration if possible ...
Vasyalisk's user avatar
  • 426
6 votes
Accepted

Small Python class for Lindenmayer Systems

This is a neat implementation of Lindenmayer systems. I have some suggestions for simplifying and organizing the code. The docstring for a method or a function comes after the ...
Gareth Rees's user avatar
  • 49.6k
6 votes
Accepted

Snake game in Pygame

There is quite a lot of code, so I'll point out the first few things that I notice. Naming: you have some constants all upper case which is good, but you also have constants that are lower case and ...
ChatterOne's user avatar
  • 2,805
6 votes
Accepted

Noughts and Crosses in Python using the pygame module

I'd remove those comments, because they don't really add anything (having something like Initialises the pygame module near ...
ChatterOne's user avatar
  • 2,805
6 votes

Counting people inside the house game

I noticed that you are repeating some of the code under animate_person_going_inside and `animate_person_going_outside functions. Also when rendering the text, some ...
alpha_989's user avatar
  • 215
6 votes
Accepted

Simple Python Pygame Game

This is a big review, and it will be hard to cover everything, so I'll go with some main points and then a few tips (having started my own game in pygame as well, if you want to take a look - it's not ...
Diane M's user avatar
  • 498
6 votes
Accepted

First OOP in Python 3: Pygame Pong

Gameplay: By placing the paddle in a specific position I managed to break the game (see the image). I think you should add a random starting angle when the game restarts. Also, as Wikipedia says ...
Georgy's user avatar
  • 1,939
6 votes

Golf game boilerplate

Overall it isn't bad. Direct imports for common symbols Based on your discretion, certain often-used and unambiguous symbols can be imported without their module namespace, i.e. ...
Reinderien's user avatar
  • 62.5k
6 votes
Accepted

How can I make my Pygame Tic Tac Toe game better?

These points are in order of how I went through your program. They are not ordered in matter of importance. Your code is suspicious from the start: ...
Mast's user avatar
  • 13.4k
6 votes

Simple PyGame Connect 4

I wish I could make a more comprehensive suggestion regarding the gigantic mass under while not done:. The sheer amount of duplication there is unsustainable. I'm ...
Carcigenicate's user avatar
6 votes

Dungeon Ball, a Pygame

I have not tried playing the game, but had a look at the code and I have some suggestions. Code readability suggestions boxSize[0] and ...
user985366's user avatar
  • 1,725

Only top scored, non community-wiki answers of a minimum length are eligible