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 ...
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 ...
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 ...
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 ...
12
votes
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 ...
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 ...
10
votes
Accepted
Simple top down shooter game
Alright, this may be something where you need/desire/end up with multiple reviews - since changing this from it's current (procedural) style to OOP is (very) unlikely to be something someone new to ...
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 ...
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'...
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 ...
9
votes
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 ...
8
votes
Setting the scene for a role-playing game
You should always close any file you open. You can guarantee this by using a context manager.
with open("some_file_name") as f:
x = int(f.readline())
This ...
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 ...
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 ...
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 ...
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 ...
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:
...
7
votes
Gomoku (Connect 5) game implementation in pygame
I can suggest a small improvement when you are checking the win with the code:
...
6
votes
Setting the scene for a role-playing game
Welcome here!
First of all, you have a lot of vars for images. Consider using image lists, like:
...
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 ...
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
...
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 ...
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 ...
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 ...
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 ...
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 ...
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.
...
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♦
- 13.1k
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
pygame × 243python × 233
python-3.x × 64
game × 46
performance × 38
beginner × 34
object-oriented × 26
snake-game × 24
python-2.x × 19
game-of-life × 8
algorithm × 7
animation × 7
numpy × 6
simulation × 6
collision × 6
image × 5
tic-tac-toe × 5
chess × 5
classes × 4
physics × 4
pong × 4
array × 3
random × 3
mathematics × 3
gui × 3