Questions tagged [pygame]
Pygame is a portable Python package for video games, built on SDL.
255 questions
4
votes
2
answers
259
views
Create Frame Widget with Pygame
I developed two custom UI components with Pygame: a Button widget and a Frame widget. After placing the Button inside the Frame, I encountered an issue with the Button’s collision detection.
...
6
votes
2
answers
503
views
Tilemap implemented in pygame
This code requires:
tile map exported as .csv file
tile set as .png
knowing tile size
knowing the rows and cols of the tile set .png
For example, this tileset has 2 rows and 6 cols
...
9
votes
2
answers
270
views
Blackjack game for assignment
I’m a first-year IT student, and I’ve completed a working Blackjack game in Python as part of an assignment. I’d love to get some feedback on my code structure, readability, and comments to improve my ...
8
votes
2
answers
1k
views
2D block game like Minecraft
I have been working on a 2D block game. I like the progress I am making, but I would like to improve the performance and the overall quality of the code. The code and textures are stored in my GitHub ...
7
votes
1
answer
125
views
Pygame self-made sprite loader
I just wanted to put this out here and see what people think and potential improvements I could make. I've been learning spritesheets in pygame as I was really scared to use them as I thought they ...
7
votes
2
answers
854
views
Numerical cellular automaton way of simulating water, fire or smoke
I have made up some evolutionary rules for a type of cellular automaton that uses numbers instead of the more common binary black or white cells.
Rules in English:
Takes place on a square grid that ...
2
votes
2
answers
303
views
Infinite 2d block world (2d minecraft) with chunk system, physics and slower loading
Follow up from this question. I have added a slower loading system that allows the main game to run faster but I still get under 30 fps with caves even if I allow the player to outrun the loading. I ...
3
votes
2
answers
275
views
Infinite 2D block world chunk system with physics
I am coding an Infinite 2D block world chunk system with physics for fun. I am worried mainly about performance and code structure. I found that when I added more Perlin noise it made the performance ...
2
votes
1
answer
126
views
Infinite 2D block world chunk system
I am coding an infinite 2D block world chunk system for fun. I would like to improve performance, but I'm not that worried.
Game.py
...
7
votes
2
answers
1k
views
chess game: loading images for the rooks
I was ok with my pawn code but the rook code is very long and I want it to make the code shorter and cleaner and the same thing with my bishops, knights, kings and queens.
...
4
votes
2
answers
197
views
"Element Fusion" game where 2048 meets Chemistry
I've developed "Element Fusion," a PyGame-based game inspired by 2048 but using chemical elements. I'm seeking feedback on:
Gameplay mechanics
Code structure and efficiency
PyGame ...
7
votes
3
answers
1k
views
Is this Python/Pygame that draws a maze well structured?
I'm not very confident about this piece of code I created, it basically takes a file like this:
## #
## ## #
#B # #
# ## ##
##
A######
Then proceeds to ...
13
votes
2
answers
2k
views
Space shooter game using pygame
I have made a space shooter game in pygame with over 800 lines of code (including blank lines). The aim of the game is to kill all of the ships in the game. You start with a small spaceship and one ...
6
votes
1
answer
173
views
Code for a basic dodging game in Python
Can someone review the code for this dodging game I made a while back? I want to see if there are any improvements or optimizations I can make as I am more or less a Python beginner.
...
2
votes
1
answer
140
views
Pong using pygame module
I made a game in Python where you play Pong against an AI. As I am quite new to pygame, I would be grateful to hear any possible improvements.
This is my code:
...
2
votes
1
answer
112
views
Agent based Dengue transmission simulation
I'm trying to implement the dynamics of Dengue transmission between mosquitoes and humans. I decided create two classes, one for the human population and another for the mosquitoes. Both are based on ...
2
votes
2
answers
911
views
How can I get my CPU Utilization Down? PYGAME PROJECT
I get 25% CPU usage on this simple project. I hope it's okay if I just post the whole thing. It probably something to do with the rendering code. It's definitely the project though, my fans get loud, ...
1
vote
1
answer
176
views
Start Screen for pygame
I'm making a Start Screen class for my game, it has 3 buttons and they're spread out horizontally on the screen. The screen also has a scrolling background, moves from top to bottom. It's a very basic ...
2
votes
1
answer
168
views
Pygame (First time trying to implement OOP)
Recently I've been trying to learn more advanced things such as using classes and creating methods and such to implement OOP into my coding. This is the first time I've tried and I want opinion on ...
4
votes
1
answer
3k
views
Very simple Flappy 'Bird' game - First project in Python
I am a beginner in Python. This is my first project in Python (that I tried to complete).
There is a grey square that acts as the Flappy 'Bird' with green obstacles spawning with random gap sizes. The ...
4
votes
1
answer
390
views
2D Minecraft - infinite chunk system
I am making a 2d minecraft clone for a hobby.
Here is my code:
2D_MC.py:
...
2
votes
2
answers
434
views
Basic pygame program template
I have a basic pygame program that I use at the start of every project that involves pygame. The idea is every time I start a project that involves pygame I can copy and past and I can immediately ...
5
votes
1
answer
343
views
2d minecraft with infinite chunk system
I've made a python game called 2d minecraft (guess where I got the idea) that has an infinite chunk system. I believe the idea I have is alright but my coding is bad and I have tried to improve it as ...
0
votes
1
answer
2k
views
Drawing a tilemap using python and pygame
I am creating a tile-map in python using pygame. The code I have (see below) works OK, but I was wandering if there were any ...
2
votes
1
answer
124
views
Game of life(random generation, pygame)
I recently created game about life in python. First version of code was console, but recently I rewrote this game in pygame. I decied upgrade game and was added age of cells. But now I can see that my ...
2
votes
0
answers
155
views
Snake game with constant time complexity algorithm
https://github.com/speedrun-program/constant_time_snake_game
Memory efficient snake game with O(1) algorithm for snake movement and bug placement.
Three grids are used:
a grid representing the game ...
2
votes
1
answer
117
views
pygame bullet spawner
I am currently making a game for myself and i have a lot of code in a function which does almost the exact same thing with some minor differences. I was wondering if there is an way to optimize this
...
3
votes
1
answer
128
views
Tap-Type-Game in Python (fast-typer)
Hello everyone
Last week I've started creating a little project for fun - TapType Game, I know there is a lot of things to make better, but what about my solution, can you give me some general tips, ...
20
votes
3
answers
4k
views
Planetary simulation in python
I have created a program in python that calculates forces between bodies (i.e earth, moon and a hypothetical moon) and make them move according to the changes in velocity and forces. This is the code ...
1
vote
1
answer
65
views
Is this a correct way of doing ECS?
I'm trying to use ECS with Pygame and was wondering if I'm doing this right before I go any deeper than this. I've tried learning more about ECS but it's mostly in another language, which I could ...
7
votes
2
answers
521
views
Solar System simulation with real values in Pygame
Inspired by TechWithTim, I built up the solar system including Pluto. I have added a camera feature, zoom feature and displaying information about the selected planet.
Zoom in and out using arrow keys,...
1
vote
1
answer
149
views
game in pygame but lots of functions with lots of parameters necessary to tidy up game loop [closed]
I'm making a game with Pygame in which the user can place machines that would output resources called producers and you can use those resources to craft items with crafters which you would then move ...
1
vote
1
answer
139
views
Snake game with Pygame
I created and finished a Snake using pygame (in Python) utilising feedback I had from a previous code review a year or two ago. I'm pretty happy with the current state and havn't identified any bugs ...
2
votes
2
answers
197
views
pixelating images
I'm a hobby programer and I had an idea for pixelating images and I wrote it.
I was wondering how would a better programer write the same function.
I want to learn and I think that this would help me ...
2
votes
2
answers
380
views
Movement and collision function
I just want this code optimized to the max and I don't mind knowing if the optimization is pretty much at the max already or if I am doing movement and collision wrong. My game is a 2d Minecraft style ...
2
votes
1
answer
405
views
Simulation of sand particle collision
I am making a module that allows you to create sand and simulate it. I have successfully done this, but it runs very slowly. I need this to be able to simulate at least 1000 particles, at a fps higher ...
3
votes
1
answer
176
views
python pygame snake game
I used numpy for the O(n) parts, but I didn't add any ability to change grid size because I still wonder if there's a way to make it better than O(n).
main.py:
<...
2
votes
1
answer
90
views
Conversion of ZX81 BASIC Game to Pygame
I got the idea for this code from an article on converting ZX81 BASIC to Pygame. Although some code was provided in the article, I implemented this myself.
I'm pretty dubious about the approach of ...
3
votes
1
answer
234
views
pygame with infinitely scrolling background - handling of sprites movement
In my current project, I try to implement the basic logic of the game "Vampire Survival" (Little impression of the first level can be seen in this video on Youtube).
Question
I want to know, ...
2
votes
1
answer
249
views
Go chess (weiqi) in Python using Pygame
Preface
This question is a re-implementation of my other question here.
The Game
Go or weiqi is an amazingly simple yet complex board game. This game is typically played on a 19x19 grid, and pieces ...
0
votes
1
answer
219
views
PyGame Event Handling
I'm new to pygame and tried to write my own Event Manager because I couldn't find a solution I was satisfied with. So I wrote my own inspired by the observer pattern:
...
2
votes
1
answer
979
views
Slot machine game using python
I made a 3 reel slot machine using the pygame library in Python. This is what I have so far.
I want to improve it to make it work for a 3x5 slot machine with multiple paylines, right now it is a 1x3 ...
3
votes
1
answer
182
views
Asteroid-avoidance arcade game in pygame
Out of boredom one day I decided to make a game in pygame. I think it turned out fine, but am absolutely sure that it can be improved. How so?
...
4
votes
1
answer
116
views
Weird things to do to an image
Here is a program I wrote to take an image and do weird things to it. Is there any more weird things I can add?
Right now I have:
Chop the image
Flip the image (up/down and left/right)
Rotate the ...
2
votes
1
answer
313
views
Sorting Algorithm Visualizer with Pygame
I've written a Sorting Algorithms Visualizer according to this tutorial, but made some changes and added some features of my own.
The visualization is made with Pygame (which I never used before).
The ...
3
votes
1
answer
199
views
PixelArt made with pygame
I am a bit new to pygame, and I made this simple pixel art game. Is it possible to simplify, and is it possible to save your drawings and load them back again?
...
2
votes
1
answer
455
views
Robotic swarm simulation: aggregation
This program simulates the phenomenon of aggregation of a swarm of robots with no cooperation between each other and each robot following a very simple rule:
The velocity of this robot has a random ...
3
votes
1
answer
92
views
Pygame Rect sorting algorithm
I need to write a program where the user can switch between rect positions.
rects position re-ordering relevant for activating other functions that not relevant for this question.
My algorithm works, ...
3
votes
1
answer
488
views
15 Puzzle in Pygame
This is a 15 puzzle implemented in pygame. The tiles can be moved with the arrow keys or by clicking and dragging the mouse. Parts of the code that require extra like icons and sound effects files ...
1
vote
1
answer
66
views
When I try to re set up my code after failing in the game I cant get it to run the function without its own file being undefined [closed]
I know my code is ugly and unreadable. I originally had the game working without class functions but when I had to implement class function it all went downhill.
TennisMaster.py
...